private void Awake() { if (_Instance == null) { _Instance = this; } DontDestroyOnLoad(this); }
/// <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); }