using Kill.Network;
using UnityEngine;
using UnityEngine.UI;
namespace Kill.UI.Components
{
///
/// 全局Loading组件
/// 调用 LoadingUI.Show() 显示,LoadingUI.Hide() 隐藏
///
public class UpdateLoadingUI : MonoBehaviour
{
public static UpdateLoadingUI Instance { get; private set; }
[Header("UI引用")]
public GameObject loadingPanel;
public PlayFlash loadingAni;
public Text precent;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
private void Start()
{
Hide();
}
///
/// 显示Loading
///
public void Show()
{
if (Instance == null) return;
Instance.loadingPanel.SetActive(true);
if (Instance.loadingAni != null)
loadingAni.Play();
}
///
/// 隐藏Loading
///
public void Hide()
{
if (Instance == null) return;
if (Instance.loadingAni != null)
Instance.loadingAni.Stop();
Instance.loadingPanel.SetActive(false);
}
public void GetDownloadProcess(DownloadProgress progress)
{
Debug.Log($"下载进度: {progress.ProgressPercentage}%");
precent.text=progress.ProgressPercentage+"%";
}
public void SetPrecent(float p)
{
int fullP=(int)(p*100);
precent.text=fullP+"%";
}
}
}