Пример #1
0
        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);
        }
Пример #2
0
 public static SimplePoolManager Instance()
 {
     if (sInstance == null)
     {
         sInstance = new SimplePoolManager();
     }
     return(sInstance);
 }
Пример #3
0
 public static SimplePoolManager Instance()
 {
     if (sInstance == null)
     {
         sInstance = new SimplePoolManager();
     }
     return sInstance;
 }
Пример #4
0
        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();
        }