/// <summary>This method will transition a scene manager from on to the other, or load the first scene manager upon load.</summary> /// <typeparam name="TSceneManager"></typeparam> /// <param name="progress"></param> /// <param name="setup"></param> /// <param name="sceneManager"></param> /// <returns></returns> /// <example> /// <code title="Example" description="" lang="CS"> /// GameManager.Transition<SceneManagerB>(sceneManagerB=>{ /// sceneManagerB.SetSomethingBeforeItsLoaded(); /// }, (message,progress)=> { Debug.Log(progress + "% " + message);</code> /// </example> public static Coroutine Transition <TSceneManager>(TSceneManager sceneManager, Action <TSceneManager> setup = null, UpdateProgressDelegate progress = null) where TSceneManager : SceneManager { if (sceneManager == null) { throw new Exception(String.Format("{0} is null or was not found while trying to load the game. Have you loaded the correct scene? Try", typeof(TSceneManager).Name)); } if (ActiveSceneManager != null) { //ActiveSceneManager.Unload(); ActiveSceneManager.enabled = false; ActiveSceneManager.gameObject.SetActive(false); Log("Deactivated old scene manager."); } ActiveSceneManager = sceneManager; ActiveSceneManager.gameObject.SetActive(true); ActiveSceneManager.enabled = true; Log("Scene Manager Enabled"); if (setup != null) { setup(sceneManager); } ActiveSceneManager.OnLoading(); Log("Beginning Scene Manager Loading"); return(Instance.StartCoroutine(LoadSceneManager(progress ?? DefaultUpdateProgress))); }
void Start() { // get the name of this level myLevelScoreData.LevelName = ActiveSceneManager.GetSceneName(); // load score and level data SaveDataScript.Load(); // chech if this level already exsists in the list of levels bool foundLevel = false; foreach (SaveDataScript.LevelScoreData levelData in SaveDataScript.MySaveData.levelScoreDataSet) { if (myLevelScoreData.LevelName == levelData.LevelName) { foundLevel = true; myLevelScoreData = levelData; break; } } // if we dont find this levels data create a new one if (!foundLevel) { SaveDataScript.MySaveData.levelScoreDataSet.Add(myLevelScoreData); } // set this level to last completed * change this to last attempted?* SaveDataScript.MySaveData.LastCompletedLevel = myLevelScoreData.LevelName; // save data SaveDataScript.Save(); }
public void SelectScene() { if (GetComponentInChildren <ScoreDisplay>().GetSelectedlevel() != "") { ActiveSceneManager.UnloadScene(currScene); ActiveSceneManager.LoadScene(GetComponentInChildren <ScoreDisplay>().GetSelectedlevel(), false); } }
/// <summary> /// Begins the the "Load" coroutine of the scenemanger passing the appropriate progress delegate. /// </summary> /// <param name="progress"></param> /// <returns></returns> private static IEnumerator LoadSceneManager(UpdateProgressDelegate progress) { // yield return new WaitForEndOfFrame(); yield return(Instance.StartCoroutine(ActiveSceneManager.Load(progress))); Log("Scene Manager Loading Complete"); ActiveSceneManager.OnLoaded(); }
// Start is called before the first frame update void Start() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
void Awake() { if (_instance == null) { _instance = this; } if (_instance != this) { DestroyImmediate(gameObject); } DontDestroyOnLoad(gameObject); }
/// <summary> /// Transitions to another scene and loads additional scene if specified. /// game assuming that it will exist in the scene after loading is finished. /// </summary> /// <typeparam name="T">The SceneManager type that will exist in the first scene specified.</typeparam> public static void TransitionLevel <T>(SwitchLevelSettings <T> settings) where T : SceneManager { if (ActiveSceneManager != null) { ActiveSceneManager.PersistantViewModels.Clear(); ActiveSceneManager.PersistantViews.Clear(); ActiveSceneManager.Unload(); ActiveSceneManager.enabled = false; ActiveSceneManager.gameObject.SetActive(false); ActiveSceneManager = null; } SwitchLevelSettings = settings; Application.LoadLevel(Instance._LoadingLevel); }
void Start() { characterActions = GetComponent <CharacterActions>(); if (instance == null) { instance = this.gameObject; } else if (instance != this.gameObject) { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); activeSceneManager = GameObject.FindGameObjectWithTag("ActiveSceneManager").GetComponent <ActiveSceneManager>(); }
// Start is called before the first frame update void Start() { ActiveSceneManager.LoadScene("MainMenu", true); }
//Method to be initiate a scene change public void SelectScene(string val) { ActiveSceneManager.UnloadScene(currScene); ActiveSceneManager.LoadScene(val, false); }
private void Start() { activeSceneManager = GameObject.FindGameObjectWithTag("ActiveSceneManager").GetComponent <ActiveSceneManager>(); }
void OnApplicationQuit() { _instance = null; DestroyImmediate(gameObject); }
// Start is called before the first frame update void Start() { sceneManager = GameObject.FindGameObjectWithTag("Scene Manager").GetComponent <ActiveSceneManager>(); //we're assuming here that there will be a scene manager in the scene to trigger this behaviour buttons = FindObjectsOfType <ContextActionButton>(); }