Пример #1
0
    public static void StartGame()
    {
    #if UNITY_EDITOR
        EditorSceneManager.LoadSceneAsync(1);
    #else
        SceneManager.LoadSceneAsync(1);
#endif
    }
Пример #2
0
    /// <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
    }
Пример #3
0
 // 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");
     }
 }
Пример #4
0
        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;
            }
        }
Пример #5
0
    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
        }
    }
Пример #6
0
    /// <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);
            }
        };
    }
Пример #7
0
 public void OnClickReturn()
 {
     EditorSceneManager.LoadSceneAsync("start");
 }
Пример #8
0
 IEnumerator BeginLoading()
 {
     async = EditorSceneManager.LoadSceneAsync("test");
     yield return(async);
 }
Пример #9
0
 IEnumerator CoLoadNextScene()
 {
     asyncV = EditorSceneManager.LoadSceneAsync("ParticleTest/ParticleNoJoy");
     asyncV.allowSceneActivation = false;
     yield return(asyncV);
 }