protected void OnDestroy() { //Clean up all the updateDelegates if (updateDelegates != null) { for (var i = 0; i < (int) SceneState.Count; i++) { updateDelegates[i] = null; } updateDelegates = null; } //Clean up the singleton instance if (appController != null) { appController = null; } }
void Awake() { if(appController != null && appController != this) Destroy(this); DontDestroyOnLoad(gameObject); //Setup the singleton instance appController = this; //Setup the array of updateDelegates updateDelegates = new UpdateDelegate[(int) SceneState.Count]; //Set each updateDelegate updateDelegates[(int) SceneState.Reset] = UpdateSceneReset; updateDelegates[(int) SceneState.Preload] = UpdateScenePreload; updateDelegates[(int) SceneState.Load] = UpdateSceneLoad; updateDelegates[(int) SceneState.Unload] = UpdateSceneUnload; updateDelegates[(int) SceneState.Postload] = UpdateScenePostload; updateDelegates[(int) SceneState.Ready] = UpdateSceneReady; updateDelegates[(int) SceneState.Run] = UpdateSceneRun; nextSceneName = "scene2"; sceneState = SceneState.Reset; //camera.orthographicSize = Screen.height / 2; }