public void UnloadLevel(string sceneFilePath, Action completeAction, bool async) { if (async) { if (QLogger.CanLogInfo) { QLogger.LogInfo("Unload of scene " + sceneFilePath + " has begun"); } AsyncOperation operation = SceneManager.UnloadSceneAsync(sceneFilePath); operation.completed += delegate(AsyncOperation o) { if (QLogger.CanLogInfo) { QLogger.LogInfo("Unload of scene " + sceneFilePath + " has completed"); } if (completeAction != null) { completeAction(); } }; } else { QLogger.LogErrorAndThrowException("We only have async version for unload as direct one was made obselete by unity"); } }
// Prevent the class from behind created by the client protected virtual void Awake() { if (QLogger.CanLogInfo) { QLogger.LogInfo(string.Format("{0} instantiated.", typeof(T))); } if (uniqueInstance == null) { uniqueInstance = this; } else if (uniqueInstance != this) { QLogger.LogErrorAndThrowException("Cannot have two instances of a SingletonMonoBehaviour : " + typeof(T).ToString() + "."); } }
public void LoadLevel(string sceneFilePath, bool additive, Action completeAction, bool async) { if (!isInitiated) { Initialize(); } if (QLogger.CanLogInfo) { QLogger.LogInfo("Load scene " + sceneFilePath + " has begun"); } if (async) { AsyncOperation operation = SceneManager.LoadSceneAsync(sceneFilePath, additive ? LoadSceneMode.Additive : LoadSceneMode.Single); operation.completed += delegate(AsyncOperation o) { if (QLogger.CanLogInfo) { QLogger.LogInfo("Load scene " + sceneFilePath + " has completed"); } if (completeAction != null) { completeAction(); } }; } else { SceneManager.LoadScene(sceneFilePath, additive ? LoadSceneMode.Additive : LoadSceneMode.Single); if (completeAction != null) { if (QLogger.CanLogInfo) { QLogger.LogInfo("Load scene " + sceneFilePath + " has completed"); } completeAction(); } } }