//CoLoadGame에서 사용하는 함수
    //프로젝트에서는 주석처리하고 OnFadeIn을 사용 중
    //www로 로딩하는 외부 리소스가 없다면 주석 해제하고 이것을 사용하자.
    IEnumerator CoDoneCheck()
    {
        //씬이 완전히 넘어갔는지 무한 체크!
        while (!async.isDone)
        {
            yield return(null);
        }

        Debug.Log("넘어간뒤" + async.isDone);
        if (async.isDone)
        {
            if (LoadPageProgressImg != null && LoadPage != null)
            {//별도의 이미지를 사용중이라면 마지막 갱신 뒤 비활성화해주자.
             //카메라 페이드 아웃
                if (LoadPageProgressImg != null)
                {
                    LoadPageProgressImg.fillAmount = async.progress;
                }
                this.fadeInOutCtrl.FadeOut(this.FadeOutTime);
                yield return(new WaitForSeconds(this.FadeOutTime));

                LoadPage.SetActive(false);
            }
        }

        // 로드가 끝난후 페이드 인 들어가게 바꾼다.
        this.fadeInOutCtrl.FadeIn(this.FadeInTime);

        //로딩이 끝났으니 END로.
        sceneState = SCENESTATE.END;
    }
예제 #2
0
    public override void Execute()
    {
        Debug.Log("StartCount");

        Debug.Log("time = " + StartCount);
        switch (sceneState)
        {
        case SCENESTATE.INITIALIZE:
            ref_gameManager.countDownTimer.SetActive(true);
            sceneState = SCENESTATE.COUNT;
            break;

        case SCENESTATE.COUNT:
            StartCount += Time.deltaTime;
            if (PrevStartCount != (int)(StartCount / 1.0f))
            {
                PrevStartCount = (int)(StartCount / 1.0f);
                ref_gameManager.TimeCountUI.text = ((int)EndTime - PrevStartCount).ToString();
                if (StartCount >= EndTime)
                {
                    StartCount = 0.0f;
                    ref_gameManager.TimeCountUI.text = "スタート!";
                    sceneState = SCENESTATE.LOGO;
                }
            }
            break;

        case SCENESTATE.LOGO:
            StartCount += Time.deltaTime;
            if (StartCount >= sceneChangeInterval)
            {
                ref_gameManager.countDownTimer.SetActive(false);
                ref_gameManager.SetGameStates(GAMESTATE.INGAME);
                ref_gameManager.se_water.Play();
            }
            break;
        }
    }
    //OnFadeIN 함수에서 호출할 코루틴
    IEnumerator CoFadeIN()
    {
        if (LoadPageProgressImg != null && LoadPage != null)
        {//별도의 이미지를 사용중이라면 마지막 갱신 뒤 비활성화해주자.
         //페이드인 따로 추가할까?

            if (LoadPageProgressImg != null)
            {
                LoadPageProgressImg.fillAmount = async.progress;
            }
            //카메라 페이드 아웃
            this.fadeInOutCtrl.FadeOut(FadeOutTime);
            yield return(new WaitForSeconds(FadeOutTime));

            LoadPage.SetActive(false);
        }

        // 로드가 끝난후 페이드 인 들어가게 바꾼다.
        this.fadeInOutCtrl.FadeIn(this.FadeInTime);

        //로딩이 끝났으니 END로.
        sceneState = SCENESTATE.END;
    }
    //OnSceneChange에서 실행시키는 코루틴 함수
    //씬 로딩에 대해 실행된다.
    IEnumerator CoLoadGame(string sceneName, bool auto)
    {
        //현재 로드상태를 설정한다.
        sceneState = SCENESTATE.LOAD;

        //카메라 페이드 아웃
        this.fadeInOutCtrl.FadeOut(this.FadeOutTime);

        //카메라가 페이드 아웃 될 시간동안 실행을 미룬다.
        yield return(new WaitForSeconds(this.FadeOutTime));


        //로딩 페이지를 활성화 시킨다.
        if (LoadPage != null)
        {
            LoadPage.SetActive(true);
            if (LoadPageProgressImg != null)
            {
                LoadPageProgressImg.fillAmount = 0.0f;
            }
            // 로드페이지가 보여주기 위해 페이드 인!!
            this.fadeInOutCtrl.FadeIn(this.FadeInTime);
            yield return(new WaitForSeconds(this.FadeInTime));

            //print("ss");
            yield return(null);
        }

        //비동기 로딩을 하기 위한 변수
        async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);

        //장면이 준비된 즉시 장면이 활성화되는 것을 막는다.
        async.allowSceneActivation = false;

        //로딩이 완료되었는지 확일할 불 변수
        bool isDone = false;

        while (!isDone)
        {
            //퍼센트 표시를 하고 싶다면 이것을 사용하자!
            //layer.text (async.progress * 111.111f + 0.00011f).ToString() + "%";

            //로딩바를 표시할 이미지가 있다면 갱신한다.
            if (LoadPageProgressImg != null)
            {
                LoadPageProgressImg.fillAmount = async.progress;
            }

            yield return(null);

            //로딩이 90% 이상이면 탈출한다.
            if (async.progress >= 0.9f)
            {
                isDone = true;
            }

            //Debug.Log((async.progress * 111.111f + 0.00011f).ToString() + "%");
        }

        //로딩바를 한번 더 갱신한다.
        if (LoadPageProgressImg != null)
        {
            LoadPageProgressImg.fillAmount = async.progress;
        }

        //장면이 준비된 즉시 장면이 활성화되는 것을 허용한다.
        async.allowSceneActivation = true;

        //로드가 끝났는지 체크할 코루틴을 실행한다.
        if (auto)
        {
            StartCoroutine(CoDoneCheck());
        }
    }