예제 #1
0
    IEnumerator IELoadScene(int sceneIndex)
    {
        isLoading = true;

        uiController.UpdateLoadingBar(0);
        yield return(StartCoroutine(uiController.Show()));


        AsyncOperation loadingScene = SceneManager.LoadSceneAsync(sceneIndex);

        while (!loadingScene.isDone)
        {
            float progress = Mathf.Clamp01(loadingScene.progress / .9f);

            uiController.UpdateLoadingBar(progress);

            yield return(null);
        }

        if (GetComponent <Canvas>())
        {
            GetComponent <Canvas>().worldCamera = Camera.main;
        }

        isLoading = false;

        yield return(new WaitForSeconds(.5f));

        yield return(StartCoroutine(uiController.Hide()));
    }
예제 #2
0
파일: GameStart.cs 프로젝트: linxscc/bnyx
    IEnumerator LoadGame(int level = 1)
    {
        if (isLoading == false)
        {
            isLoading = true;

            Application.backgroundLoadingPriority = ThreadPriority.Low;


            loadingUIController = UIManager.Instance.GetUI <LoadingUIController>("Loading");
            loadingUIController.Show();

            loadingUIController.SetProgress(0);
            yield return(null);

            Loader loader = new Loader();

            loader.Items = new List <Loader.Item>
            {
                new Loader.Item()
                {
                    stepCount = 50,
                    action    = InitAsset(50)
                },
                new Loader.Item()
                {
                    stepCount = 1500,
                    action    = LoadAssetBylabel <GameObject>("Prefab", ".prefab", 1500)
                },
                new Loader.Item()
                {
                    stepCount = 300,
                    action    = LoadAssetBylabel <AudioClip>("Music", ".wav", 300)
                },
                new Loader.Item()
                {
                    stepCount = 100,
                    action    = LoadAssetBylabel <TextAsset>("Text", ".txt", 100)
                },
                new Loader.Item()
                {
                    stepCount = 300,
                    action    = LoadAssetBylabel <Texture>("Texture", ".png", 300)
                },
                new Loader.Item()
                {
                    stepCount = 10,
                    action    = LoadSceneGame(10)
                }
            };

            IEnumerator update = loader.Update();
            while (update.MoveNext())
            {
                float percent = (float)update.Current;
                loadingUIController.SetProgress(percent);
                yield return(null);
            }
            // 完成 add by TangJian 2019/3/25 21:37
            Application.backgroundLoadingPriority = ThreadPriority.Low;

            // 隐藏UI add by TangJian 2019/3/25 22:17
//            loadingUIController.Hide();

            // 开始游戏 add by TangJian 2019/3/25 21:38
            GameManager.Instance.difficultyLevel = level;
            GameManager.Instance.StartGame();

            isLoading = false;
        }
    }