Unity__PoolManager物件池外掛
阿新 • • 發佈:2018-12-14
SpawnPool spawnPool; PrefabPool prefabPool; void InitPoolManager() { spawnPool = this.gameObject.AddComponent<SpawnPool>(); prefabPool = new PrefabPool(BruchEntity.transform); //初始化Prefab數量 prefabPool.preloadAmount = 5; //限制例項 prefabPool.limitInstances = true; //解限快取池 prefabPool.limitFIFO = true; //限制池子裡最大的Prefab數量 prefabPool.limitAmount = 1000; //每幾幀載入一個 prefabPool.preloadFrames = 2; //“非同步”載入 prefabPool.preloadTime = true; spawnPool._perPrefabPoolOptions.Add(prefabPool); spawnPool.CreatePrefabPool(spawnPool._perPrefabPoolOptions[spawnPool.Count]); } Transform getTf() { return spawnPool.Spawn(BruchEntity.transform); }