Пример #1
0
 private void Awake()
 {
     if (_Instance == null)
     {
         _Instance = this;
     }
     DontDestroyOnLoad(this);
 }
Пример #2
0
 /// <summary>
 /// Singleton Code then:
 ///     Subscribing for OnSceneLoaded Event in order to fire methods when the game starts/ the scenes loaded.
 /// </summary>
 private void Awake()
 {
     if (_Instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _Instance = this;
     }
     DontDestroyOnLoad(this);
     SceneManager.sceneLoaded += OnSceneLoaded; //Subscribe for Scene Loaded Event
 }
 private void Awake()
 {
     if (_Instance == null)
     {
         _Instance = this;
     }
     else
     {
         if (this.gameObject)
         {
             Destroy(this.gameObject);
         }
     }
     DontDestroyOnLoad(this);
 }