Exemplo n.º 1
0
    protected IEnumerator SceneLoadCorountine(GameObject sceneObj)
    {
        bool isFade = true;

        StartCoroutine(FadeScene.Instance.FadeOut(() => isFade = false));
        while (isFade)
        {
            yield return(null);
        }
        if (NowScene != null)
        {
            NowScene.Destroy();
        }
        float elapsedTime = Time.time;

        NowScene = Instantiate(sceneObj, SceneRoot.transform).GetComponent <SceneBase>();
        NowScene.Initilize();
        yield return(StartCoroutine(NowScene.DoInitialize()));

        elapsedTime = Time.time - elapsedTime;

        // フェードアニメーションの間隔を最低限あける
        if (elapsedTime < FadeSpaceTime)
        {
            yield return(new WaitForSeconds(FadeSpaceTime - elapsedTime));
        }
        StartCoroutine(FadeScene.Instance.FadeIn(() => isFade = false));
        while (isFade)
        {
            yield return(null);
        }
        NowScene.OnCompleteInitialize();
    }