| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class LoadingView : PinBallUIBase
- {
- public Slider slider_Loading;
- public Text text_Progress;
- protected override void Init()
- {
- base.Init();
- slider_Loading = transform.Find("slider_Loading").GetComponent<Slider>();
- text_Progress = transform.Find("text_Progress").GetComponent<Text>();
- }
- protected override void ShowUIOpt(object[] args)
- {
- string sceneName = args[0].ToString();
- StartCoroutine(AsyncLoadScene(sceneName));
-
- }
- /// <summary>
- /// 游戏开始后的实时时间(以秒为单位)(只读)。
- /// </summary>
- float timeOnStartLoadScene;
- IEnumerator AsyncLoadScene(string sceneName)
- {
- timeOnStartLoadScene = Time.realtimeSinceStartup;
- //加载场景名
-
- //if (LoginMgr.HasToken())
- //{
- // sceneName = "Home";
- //}
- //异步加载场景
- AsyncOperation async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
- //阻止当加载完成自动切换
- async.allowSceneActivation = false;
- while (!async.isDone)
- {
- slider_Loading.value = async.progress;
- text_Progress.text = async.progress * 100 + "%";
- if (async.progress >= 0.9f)
- {
- break;
- }
- yield return new WaitForSeconds(1);
- }
- //while (!appVersionCheckOK)
- //{
- // yield return null;
- //}
- //while (Time.realtimeSinceStartup - timeOnStartLoadScene < 1.5)
- //{
- // yield return null;
- //}
- async.allowSceneActivation = true;
- //PinBallUIManager.instance.DestroyUI(new object[] { "LoadingView" });
- PinBallUIManager.instance.DestroyAllUI();
- //SetTip("软件版本校验成功", Color.green);
-
- // yield return null;
- if (sceneName == "Start")
- {
- PinBallUIManager.instance.ShowUI(new object[] { "StartGameView" });
- }
- }
- protected override void HideUIOpt()
- {
-
- }
- }
|