diff --git a/meng_yao/Assets/script/ConnactServer/Logo_in.cs b/meng_yao/Assets/script/ConnactServer/Logo_in.cs index 4d1c53684..06e73dc9b 100644 --- a/meng_yao/Assets/script/ConnactServer/Logo_in.cs +++ b/meng_yao/Assets/script/ConnactServer/Logo_in.cs @@ -14,9 +14,12 @@ public class Logo_in : mount public Slider sceneslider; public Button logo_inbtn; - public float loadSpeed = 0.5f; // 填充速度 - public float loadDuration = 5f; // 总加载时间,用于计时器控制 + + public float loadDuration = 10f; // 总加载时间,用于计时器控制 public float smoothingSpeed = 0.1f; + float progress = 0; + float timer = 0f; + public override void Awake() { @@ -139,26 +142,40 @@ public class Logo_in : mount gameObject.SetActive(false); Promptmgr.Instance.PromptBubble("登录成功"); - StartCoroutine(LoadSceneWithProgress()); + + StartCoroutine(jiaLoading()); } }); } + IEnumerator jiaLoading() + { + while (timer <= 3f) + { + // 更新计时器进度 + timer +=Time.deltaTime; + progress = Mathf.Clamp01(timer / loadDuration); + // 设置进度条的值 + sceneslider.value = progress; + yield return new WaitForSeconds(0.01f); + } + StartCoroutine(LoadSceneWithProgress()); + } + IEnumerator LoadSceneWithProgress() { + // 开始异步加载场景 AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(JumpScene.scene_Main); asyncLoad.allowSceneActivation = false; - - float timer = 0f; - + while (!asyncLoad.isDone) { // 更新计时器进度 timer += Time.deltaTime; - float progress = Mathf.Clamp01(timer / loadDuration); + progress = Mathf.Clamp01(timer / loadDuration); // 设置进度条的值 sceneslider.value = progress;