using UniFramework.Pooling; using UnityEngine; using System.Collections.Generic; namespace GFGGame { public class GFGSpawner { private Spawner _entitySpawner; private Dictionary poolCreated = new Dictionary(); 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; } } }