public static void StartGame() { #if UNITY_EDITOR EditorSceneManager.LoadSceneAsync(1); #else SceneManager.LoadSceneAsync(1); #endif }
/// <summary> /// Attempt to load scene additively. /// </summary> /// <param name="scene">Scene name.</param> /// <returns>Returns enumerator.</returns> public IEnumerator LoadSceneAdditive(string scene) { #if UNITY_EDITOR // Yield return the loaded scene operation. yield return(EditorSceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive)); #else // Yield return the loaded scene operation. yield return(SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive)); #endif }
// Detects a collision with Circle component because it has the collision component void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.CompareTag("Boomerang")) { EditorSceneManager.LoadSceneAsync(0); print("Game over"); } if (coll.gameObject.CompareTag("Enemy")) { EditorSceneManager.LoadSceneAsync(0); print("Game over"); } }
public void LoadScene(string scenepath, UnityEngine.SceneManagement.LoadSceneMode mode) { Application.backgroundLoadingPriority = loadingPriority; #if UNITY_EDITOR AsyncOperation op = EditorSceneManager.LoadSceneAsync(scenepath, mode); #else AsyncOperation op = SceneManager.LoadSceneAsync(scenepath, mode); #endif if (op != null) { op.allowSceneActivation = false; mCurrentLoadOps.Add(op); currentState = LoadingState.Loading; } }
IEnumerator LoadNewScene() { coroutineStarted = true; yield return(new WaitForSeconds(0.5f)); AsyncOperation unload = SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().name); if (unload == null) { } else { while (!unload.isDone) { loadText.text = "Unloading Level " + Mathf.Round(unload.progress * 100).ToString() + "%"; yield return(null); } } if (Application.isEditor == false) { AsyncOperation async = SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single); while (!async.isDone) { loadText.text = message + Mathf.Round(async.progress * 100).ToString() + "%"; yield return(null); } } else { #if UNITY_EDITOR AsyncOperation async = EditorSceneManager.LoadSceneAsync(scene, LoadSceneMode.Single); while (!async.isDone) { loadText.text = "EDITOR: " + message + Mathf.Round(async.progress * 100).ToString() + "%"; yield return(null); } #endif } }
/// <summary> /// 异步加载场景 /// </summary> /// <param name="sceneName">场景名</param> /// <param name="loaded">下一个打开的场景</param> public void AsyncLoadScene(string sceneName, Action loaded) { AsyncOperation asyncOperation = EditorSceneManager.LoadSceneAsync(sceneName); GameRoot.Instance.loadingWind.SetWindState(true); progressCB = () => { float pro = asyncOperation.progress; GameRoot.Instance.loadingWind.SetProgress(pro); if (pro == 1) { if (loaded != null) { loaded(); } progressCB = null; asyncOperation = null; GameRoot.Instance.loadingWind.SetWindState(false); } }; }
public void OnClickReturn() { EditorSceneManager.LoadSceneAsync("start"); }
IEnumerator BeginLoading() { async = EditorSceneManager.LoadSceneAsync("test"); yield return(async); }
IEnumerator CoLoadNextScene() { asyncV = EditorSceneManager.LoadSceneAsync("ParticleTest/ParticleNoJoy"); asyncV.allowSceneActivation = false; yield return(asyncV); }