/// <summary> /// Use this: SetGameState(Object.FindObjectOfType<GameState>()); /// </summary> /// <param name="newSceneState"></param> public void SetGameState <T>() where T : SceneState { newSceneState = FindObjectOfType <T>(); if (newSceneState == null) { Debug.LogError("The specified gamestate equals null!"); return; } if (currentGameState == newSceneState) { Debug.LogWarning("You are trying to start the current gamestate again, aborted!"); return; } if (currentGameState != null) { currentGameState.Disable(); } this.currentGameState = newSceneState; if (OnStateChange != null) { OnStateChange(); } //Application.LoadLevel(currentGameState.selectedScene); // Deprecation fix StartCoroutine(WaitForLevelToLoad()); }