1234567891011121314151617181920212223242526272829303132 |
- using UniFramework.Pooling;
- using UnityEngine;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class GFGSpawner
- {
- private Spawner _entitySpawner;
- private Dictionary<string, bool> poolCreated = new Dictionary<string, bool>();
- public void Init()
- {
- // 创建游戏对象发生器
- _entitySpawner = UniPooling.CreateSpawner(VersionController.DefaultPackage);
- }
- public GameObject SpawnSync(string resPath)
- {
- poolCreated.TryGetValue(resPath, out bool created);
- if (!created)
- {
- // 创建游戏对象池
- _entitySpawner.CreateGameObjectPoolAsync(resPath);
- }
- var handle = _entitySpawner.SpawnSync(resPath);
- return handle.GameObj;
- }
- }
- }
|