/// <summary> /// Unloads a scene asynchronously, dispatching the appropriate unload events. /// </summary> static public AsyncOperation UnloadAsync(SceneBinding inScene, object inContext = null, UnloadSceneOptions inOptions = UnloadSceneOptions.None) { if (!inScene.IsValid()) { Debug.LogErrorFormat("Cannot unload invalid scene '{0}'", inScene.Path); return(null); } inScene.BroadcastUnload(inContext); return(SceneManager.UnloadSceneAsync(inScene.Scene, inOptions)); }
/// <summary> /// Loads a scene asynchronously, dispatching the appropriate load and unload events. /// </summary> static public AsyncOperation LoadAsync(SceneBinding inScene, object inContext = null, LoadSceneMode inMode = LoadSceneMode.Single) { if (!inScene.IsValid()) { Debug.LogErrorFormat("Cannot load invalid scene '{0}'", inScene.Path); return(null); } if (inMode == LoadSceneMode.Single) { foreach (var scene in FindScenes(SceneCategories.Loaded)) { scene.BroadcastUnload(inContext); } } AsyncOperation loadOp = SceneManager.LoadSceneAsync(inScene.Path, inMode); loadOp.completed += (AsyncOperation op) => { inScene.BroadcastLoaded(inContext); }; return(loadOp); }