2024-12-14 18:27:59 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using QFramework;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace QFramework.Example
|
|
|
|
|
{
|
|
|
|
|
public class UILoadingData : UIPanelData
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public partial class UILoading : UIPanel
|
|
|
|
|
{
|
2025-03-19 11:33:30 +08:00
|
|
|
AsyncOperation ao;
|
2024-12-14 18:27:59 +08:00
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
|
|
|
{
|
|
|
|
|
mData = uiData as UILoadingData ?? new UILoadingData();
|
2025-01-09 09:43:15 +08:00
|
|
|
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2025-01-13 09:39:11 +08:00
|
|
|
TypeEventSystem.Global.Register<OnLoadingShow>(arg =>
|
|
|
|
|
{
|
|
|
|
|
if (gameObject.activeSelf == false)
|
|
|
|
|
{
|
|
|
|
|
Show();
|
|
|
|
|
}
|
|
|
|
|
}).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2024-12-14 18:27:59 +08:00
|
|
|
TypeEventSystem.Global.Register<OnLoadingHide>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 11:33:30 +08:00
|
|
|
public void SetAsyncOperation(AsyncOperation ao)
|
|
|
|
|
{
|
|
|
|
|
this.ao = ao;
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
|
|
|
{
|
2025-03-19 11:05:35 +08:00
|
|
|
//Icon.GetComponent<DOTweenAnimation>().DORestart();
|
2025-03-19 11:33:30 +08:00
|
|
|
Progress.text = "";
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
2025-03-19 11:33:30 +08:00
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (ao != null)
|
|
|
|
|
{
|
|
|
|
|
Progress.text = ao.progress.ToString("P0");
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|