From ac7a95d834b4ef2f5904f54bd4173002b6ff52b7 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Thu, 05 Nov 2020 16:59:08 +0800 Subject: [PATCH] Load页面增加进度条 --- Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs | 48 +++++++++++++++++++++++++++++------------------- 1 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs b/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs index 539a428..d3f68db 100644 --- a/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs +++ b/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs @@ -25,6 +25,9 @@ transform.Find("Panel/Button").GetComponent<Button>().onClick.AddListener(OnClickLoginBtn); transform.Find("Panel/Button (1)").GetComponent<Button>().onClick.AddListener(OnClickResetBtn); + progressSlider = transform.Find("Progress").GetComponent<Slider>(); + + progressSlider.value = 0; if (Application.platform == RuntimePlatform.Android) { //GetetDeviceIMEI();//获取安卓手机IMEI @@ -85,9 +88,11 @@ AudioSourceManager.Ins.Play(AudioEnum.UI); TDAA_SDKManager.Ins.Statistics(2);//埋点 - //StartCoroutine(loginMy()); - StartCoroutine(LoadScene()); - }else{ + StartCoroutine(loginMy()); + //StartCoroutine(LoadScene()); + } + else + { } @@ -217,24 +222,26 @@ IEnumerator LoadScene() { async = SceneManager.LoadSceneAsync(GameConfig.NextSceneName); - async.allowSceneActivation = true; - /*while (!async.isDone) + //async.allowSceneActivation = true; + while (!async.isDone) { - if (async.progress < 0.9f) - progressValue = async.progress; + { + Debug.Log(async.progress); + + } + //progressValue = async.progress; else - progressValue = 1.0f; - slider.value = progressValue; - progress.text = (int)(slider.value * 100) + " %"; - + Debug.Log("超过0.9,"); + //progressValue = 1.0f; + //slider.value = progressValue; + //progress.text = (int)(slider.value * 100) + " %"; + if (async.progress >= 0.89) { - Debug.Log("进展时间分别是:" + async.progress + "," + totalTime); - if( totalTime >= 3.0f ) - async.allowSceneActivation = true; - - progress.text = "按任意键继续"; + Debug.Log("进展时间分别是:" + async.progress + ","); + + //progress.text = "按任意键继续"; if (Input.anyKeyDown) { async.allowSceneActivation = true; @@ -243,11 +250,11 @@ } //yield return null; - }*/ + } yield return null; } - + private Slider progressSlider; IEnumerator loginMy() { int displayProgress = 0; @@ -256,10 +263,11 @@ op.allowSceneActivation = false; while (op.progress < 0.9f) //此处如果是 <= 0.9f 则会出现死循环所以必须小0.9 { - toProgress = (int)op.progress * 100; + toProgress = (int)(op.progress * 100); while (displayProgress < toProgress) { ++displayProgress; + progressSlider.value = displayProgress * 0.01f; SetLoadingPercentage(displayProgress); yield return new WaitForEndOfFrame();//ui渲染完成之后 } @@ -268,6 +276,8 @@ while (displayProgress < toProgress) { ++displayProgress; + progressSlider.value = displayProgress * 0.01f; + SetLoadingPercentage(displayProgress); yield return new WaitForEndOfFrame(); } -- Gitblit v1.9.1