using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UI_LoadingPanel : BasePanel { public Slider loadSlider; private float currentProgress = 0; public float targetProgress; public bool isLoading = false; protected override void Awake() { base.Awake(); loadSlider = GetControl("loadSlider"); } public override void ShowMe() { base.ShowMe(); Debug.Log("UI_LoadingPanel ShowMe"); Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.UpdateProgress, UpdateProgress); } public override void HideMe() { base.HideMe(); Debug.Log("UI_LoadingPanel HideMe"); Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.UpdateProgress, UpdateProgress); } private void Update() { if (isLoading) { if (currentProgress < targetProgress) { currentProgress += Time.deltaTime; if (currentProgress >= targetProgress) currentProgress = targetProgress; loadSlider.value = currentProgress; } else { isLoading = false; Bootstrap.Instance.uiManager.HidePanel(); } } } private void UpdateProgress(float progress) { isLoading = true; targetProgress += progress; } }