修改main
This commit is contained in:
68
Assets/Main/Script/Runtime/LasterDoMain/ProgressBarPanel.cs
Normal file
68
Assets/Main/Script/Runtime/LasterDoMain/ProgressBarPanel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.AudioCore;
|
||||
using Stary.Evo.InformationSave;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class ProgressBarPanel : BasePanel
|
||||
{
|
||||
static readonly string path = "ProgressBarPanel";
|
||||
|
||||
private Image _fill;
|
||||
private Text _fillText;
|
||||
private Text _fillMessage;
|
||||
public ProgressBarPanel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Initialize(GameObject panelGo)
|
||||
{
|
||||
base.Initialize(panelGo);
|
||||
|
||||
_fill = activePanel.transform.Find("Fill").GetComponent<Image>();
|
||||
_fillText = _fill.transform.Find("FillText").GetComponent<Text>();
|
||||
_fillMessage= _fill.transform.Find("FillMessage").GetComponent<Text>();
|
||||
_fill.fillAmount = 0;
|
||||
_fillText.text = "0%";
|
||||
}
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
|
||||
this.RegisterEvent<ProgressBarType,string, float>(ProgressBarType.Add, SetProgressBarValue);
|
||||
}
|
||||
|
||||
public override void OnExit(float delay = 0)
|
||||
{
|
||||
base.OnExit(delay);
|
||||
_fill.fillAmount = 0;
|
||||
_fillText.text = "0%";
|
||||
this.UnRegisterEvent<ProgressBarType,string, float>(ProgressBarType.Add, SetProgressBarValue);
|
||||
}
|
||||
|
||||
public async void SetProgressBarValue(string message,float value)
|
||||
{
|
||||
_fill.fillAmount = value;
|
||||
_fillMessage.text = message;
|
||||
_fillText.text = $"{value:P0}";
|
||||
if (value >= 1)
|
||||
{
|
||||
this.PanelSystem.PopQueue<ProgressBarPanel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum ProgressBarType
|
||||
{
|
||||
Add,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user