Esempio n. 1
0
 private static void OnSceneLoaded(AssetRequest assetRequest)
 {
     //调用ui模块的进入场景
     UIModule.SceneEnter();
     // 当前场景OnEnter
     m_curScene.OnEnter();
     //发送场景切换事件
 }
Esempio n. 2
0
    /// <summary>
    /// シーン入る時に呼ばれる
    /// </summary>
    /// <param name="prevScene">Previous scene.</param>
    /// <param name="nextScene">Next scene.</param>
    private void OnEnter(Scene prevScene, Scene nextScene)
    {
        if (sceneBase != null)
        {
            sceneBase.OnEnter();
        }

        ShowBarrior(false);
    }
Esempio n. 3
0
    // 进入场景
    public static void EnteredScene(SceneEnum state)
    {
        currentSceneState = state;
        if (!SceneDic.ContainsKey(state))
        {
            Debug.LogError("SceneState is null : " + state);
            return;
        }

        m_CurrentScene = SceneDic[currentSceneState];
        m_CurrentScene.OnEnter();
    }
Esempio n. 4
0
    private IEnumerator OnTransitionCoroutine<T>(string resourceName, float fadeInDuration, float fadeOutDuration, System.Action<eSceneTransitionErrorCode> completed) where T : SceneBase
    {
        string currentPageType = m_currentScene ? m_currentScene.GetType().ToString() : string.Empty;
        string nextPageType = typeof(T).ToString();

        Global.WidgetMgr.ShowLoadingWidget(fadeInDuration, currentPageType, nextPageType);

        yield return new WaitForEndOfFrame();

        if (m_currentScene != null)
        {
            m_priviousPageTypeName = currentPageType;

            m_currentScene.OnFinalize();
            m_currentScene.OnExit();
        }

        yield return new WaitForEndOfFrame();

        float currentProgress = 0.0f;
        const float sceneLoadingProgressRate = 0.4f;

        if (string.IsNullOrEmpty(resourceName) == false)
        {
            UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            if (activeScene != null)
            {
                m_priviousResourceName = activeScene.name;
            }

            yield return Global.ResourceMgr.LoadSceneAsync(resourceName,
                (progress) =>
                {
                    // scene loading..
                    currentProgress = progress * sceneLoadingProgressRate;
                    Global.WidgetMgr.SetLoadingProgressInfo(currentProgress);

                    LogWarning(StringUtil.Format("OnTransitionCoroutine -> LoadScene {0} %", (int)(currentProgress * 100)));
                },
                () =>
                {
                    // completed scene load
                    currentProgress = sceneLoadingProgressRate;
                    Global.WidgetMgr.SetLoadingProgressInfo(currentProgress);

                    LogWarning("OnTransitionCoroutine -> Completed LoadScene.");
                });
        }
        else
        {
            currentProgress = sceneLoadingProgressRate;
        }

        m_currentScene = FindPage(typeof(T).ToString());

        if (m_currentScene == null)
        {
            m_currentScene = ComponentFactory.GetChildComponent<T>(RootObject != null ? RootObject : Setting.gameObject, IfNotExist.AddNew);
            AddPage(m_currentScene);
        }

        if (m_currentScene != null)
        {
            yield return m_currentScene.OnEnter(currentProgress);
            m_currentScene.OnInitialize();
        }

        yield return new WaitForEndOfFrame();

        if (completed != null)
        {
            Global.WidgetMgr.HideLoadingWidget(fadeOutDuration);
            completed(eSceneTransitionErrorCode.Success);
        }

        m_transitionCoroutine = null;
    }