Ejemplo n.º 1
0
    public void SetLoadingUI()
    {
        if (createLoadingUI == null)
        {
            Debug.LogError("UIManager CreateIngameUI is Null !!");
            return;
        }

        if (loadingUI == null)
        {
            GameObject go = Instantiate(createLoadingUI, transform);
            loadingUI = go.GetComponent <LoadingUIController>();
        }

        if (lobbyUI != null)
        {
            lobbyUI.gameObject.SetActive(false);
        }

        if (inGameUI != null)
        {
            inGameUI.gameObject.SetActive(false);
        }

        loadingUI.SetLoadingUI();

        SetMainCanvasScale(loadingUI.GetComponent <CanvasScaler>());
    }
Ejemplo n.º 2
0
    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;
        }
    }
Ejemplo n.º 3
0
    public override void Awake()
    {
        base.Awake();

        uiController = GetComponent <LoadingUIController>();
    }