Ejemplo n.º 1
0
 private void Awake()
 {
     if (awake)
     {
         return;
     }
     else if (instance == null)
     {
         awake    = true;
         instance = this;
         DontDestroyOnLoad(this);
         if (Prefabs != null)
         {
             foreach (var prefab in Prefabs)
             {
                 SpawningPool.AddPrefab(prefab.name, prefab);
             }
         }
         UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneWasLoaded;
     }
     else
     {
         Object.Destroy(gameObject);
     }
 }
Ejemplo n.º 2
0
 private void Awake()
 {
     if (awake)
     {
         return;
     }
     else if (instance == null)
     {
         awake    = true;
         instance = this;
         DontDestroyOnLoad(this);
         if (Prefabs != null)
         {
             foreach (var prefab in Prefabs)
             {
                 SpawningPool.AddPrefab(prefab.Key, prefab.Prefab);
             }
         }
         UnityEngine.SceneManagement.SceneManager.sceneLoaded += (scene, mode) =>
         {
             SpawningPool.RecycleActiveObjects();
         };
     }
     else
     {
         Object.Destroy(gameObject);
     }
 }