private void Awake() { if (IsDontDestroyOnLoad) { Object.DontDestroyOnLoad(gameObject); } Group = transform; if (string.IsNullOrEmpty(PoolName)) { PoolName = Group.name.Replace("Pool", ""); PoolName = PoolName.Replace("(Clone)", ""); } if (LogMessages) { Debug.Log(string.Format("SpawnPool {0}: Initializing..", PoolName)); } for (int i = 0; i < PerPrefabPoolOptions.Count; ++i) { if (PerPrefabPoolOptions[i].Prefab == null) { continue; } PerPrefabPoolOptions[i].InstanceConstructor(); CreatePrefabPool(PerPrefabPoolOptions[i]); } SimplePoolManager.Instance().AddSpawnPool(this); }
private void OnDestroy() { if (LogMessages) { Debug.Log(string.Format("SpawnPool {0}: Destroying...", PoolName)); } SimplePoolManager.Instance().RemoveSpawnPool(this); StopAllCoroutines(); mSpawned.Clear(); foreach (PrefabPool pool in mPrefabPools) { pool.SelfDestruct(); } mPrefabPools.Clear(); mPrefabs.Clear(); }