private void OnDestroy() { SceneManager.activeSceneChanged -= OnActiveSceneChanged; Logger.log?.Debug($"{name}: OnDestroy()"); instance = null; }
private void Awake() { if (instance != null) { Logger.log?.Warn($"Instance of {this.GetType().Name} already exists, destroying."); GameObject.DestroyImmediate(this); return; } GameObject.DontDestroyOnLoad(this); // Don't destroy this object on scene changes instance = this; Logger.log?.Debug($"{name}: Awake()"); SceneManager.activeSceneChanged += OnActiveSceneChanged; }