IEnumerator Loading() { progress_slider.value = 0; progress_text.text = "0%"; float progress = 0; float speed; float nowTime = Time.realtimeSinceStartup; float loadingtime; if (!GameManager.GetIsPackB()) { StartCoroutine("WaitFor"); } while (progress < 1) { yield return(null); float deltatime = Mathf.Clamp(Time.unscaledDeltaTime, 0, 0.04f); loadingtime = Time.realtimeSinceStartup - nowTime; if (GameManager.GetIsPackB()) { speed = 1; } else { speed = loadingtime >= maxloadingWaitTime ? 1 : 0.1f; } progress += deltatime * speed; progress = Mathf.Clamp(progress, 0, 1); progress_slider.value = progress; progress_text.text = (int)(progress * 100) + "%"; } StopCoroutine("WaitFor"); UIManager.ClosePopPanelByID(UI_ID); UIManager.ReleasePanel(this); GameManager.Instance.WhenLoadingGameEnd(); }