public class MyPoolTest : MonoBehaviour
{
private SpawnPool spawnPool;
private PrefabPool refabPool;
void init(){
spawnPool = PoolManager.Pools.Create("aabb");
spawnPool = PoolManager.Pools.Create("aabb");
spawnPool.group.parent = this.transform;
// spawnPool.name = "aabb";
spawnPool.logMessages = true;
spawnPool.dontDestroyOnLoad = true;
// spawnPool = PoolManager.Pools["aabb"];
refabPool = new PrefabPool(Resources.Load<Transform>("Sphere"));
/*
this.pool = PoolManager.Pools.Create(this.poolName);
// Make the pool‘s group a child of this transform for demo purposes
this.pool.group.parent = this.transform;
// Set the pool group‘s local position for demo purposes
this.pool.group.localPosition = new Vector3(1.5f, 0, 0);
this.pool.group.localRotation = Quaternion.identity;
*/
}
if (!spawnPool._perPrefabPoolOptions.Contains(refabPool))
{
Debug.Log("初始化内存池 refabPool");
refabPool = new PrefabPool(Resources.Load<Transform>("Sphere"));
refabPool.preloadAmount = 12;
refabPool.limitInstances = true;
refabPool.cullDespawned = true;
refabPool.cullAbove = 2;
refabPool.cullDelay = 2;
refabPool.cullMaxPerPass = 3;
spawnPool._perPrefabPoolOptions.Add(refabPool);
spawnPool.CreatePrefabPool(spawnPool._perPrefabPoolOptions[spawnPool.Count]);
}
}
void Start () {
GameObject go = GameObject.Find("GameObject") as GameObject;
go.AddComponent<MyPoolTest>();
}