Files
Fishing2/Assets/Scripts/UI/Loading/LoadingPanel.cs
2025-11-12 17:24:02 +08:00

66 lines
1.5 KiB
C#

// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using Fantasy.Event;
using UnityEngine;
using NBC;
using NBC.Event;
namespace NBF
{
public struct LoadingShowParam
{
public int Style;
public int StartProgress;
public LoadingShowParam(int style, int startProgress)
{
StartProgress = startProgress;
Style = style;
}
}
public class OnLoadingProgressEvent : EventSystem<LoadingProgress>
{
protected override void Handler(LoadingProgress self)
{
LoadingPanel.SetProgress(self.Progress);
}
}
public partial class LoadingPanel : UIPanel
{
public static readonly LoadingTask<LoadingPanel> LoadingTask = new();
private static LoadingPanel _loadingPanel;
public static void SetProgress(float progress)
{
if (_loadingPanel != null)
{
_loadingPanel.Progress.value = progress * 100;
}
}
protected override void OnInit()
{
ContentPane.sortingOrder = UIDef.UIOrder.Loading;
_loadingPanel = this;
Progress.max = 100;
}
protected override void OnShow()
{
base.OnShow();
Progress.value = 100;
}
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}