void Start() { //Unity Singleton: if this manager already exists, destroy this instance if (instance != null) { Debug.LogWarning("Another instance of SceneSwitchManager was detected, killing this one now"); GameObject.Destroy(this.gameObject); return; } instance = this; GameObject.DontDestroyOnLoad(this.gameObject); }
// void Awake() { if (m_instance == null) { m_instance = this; DontDestroyOnLoad(this.gameObject); } else { XLogger.LogWarning("This object is there are already."); Destroy(this.gameObject); } }
public static void LoadScene(string name, bool enableLoadScene = true) { if (m_instance != null) { SceneSwitchManager sm = m_instance.GetComponent <SceneSwitchManager>(); sm.nextSceneName = name; sm.LoadNextScene(enableLoadScene); return; } XLogger.LogWarning(LibConstants.ErrorMsg.GetMsgNotFoundObject("SceneSwitchManager")); XLogger.LogWarning("Force call LoadLevel() : " + name); SceneManager.LoadScene(name); }
void Awake() { InitKeyBindings(); DontDestroyOnLoad(this); if (sceneSwitchManagerInstance == null) { sceneSwitchManagerInstance = this; } else { DestroyObject(gameObject); } }
public void OnDestroy() { Instance = null; }
public void Awake() { Instance = this; }
private void Start() { sceneSwitch = FindObjectOfType <SceneSwitchManager>(); }