83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using DG.Tweening;
|
|
using System.Runtime.CompilerServices;
|
|
using static OperationController;
|
|
|
|
namespace QFramework.Example
|
|
{
|
|
public class UIHintData : UIPanelData
|
|
{
|
|
public bool isShowIcon = true;
|
|
public string txt;
|
|
public float time = -1;
|
|
public string audio;
|
|
}
|
|
public partial class UIHint : UIPanel
|
|
{
|
|
ResLoader loader;
|
|
protected override void OnInit(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIHintData ?? new UIHintData();
|
|
SetItem(0);
|
|
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
|
|
}
|
|
|
|
private void OnStepChanged(StepStatusOnChange change)
|
|
{
|
|
Hide();
|
|
}
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIHintData ?? new UIHintData();
|
|
Icon.gameObject.SetActive(mData.isShowIcon);
|
|
Label.text = mData.txt;
|
|
SetItem(1);
|
|
if (mData.time != -1)
|
|
{
|
|
ActionKit.Delay(mData.time, () =>
|
|
{
|
|
SetItem(0);
|
|
|
|
}).Start(this);
|
|
}
|
|
if (string.IsNullOrEmpty(mData.audio) == false)
|
|
{
|
|
string path = Global.audioPath + mData.audio;
|
|
loader = ResLoader.Allocate();
|
|
loader.Add2Load(path.ToLocalAudioResName(), (success, res) =>
|
|
{
|
|
if (success)
|
|
{
|
|
AudioKit.PlayVoice(res.Asset.As<AudioClip>(), false);
|
|
}
|
|
});
|
|
loader.LoadAsync();
|
|
}
|
|
}
|
|
|
|
public void SetItem(float alph)
|
|
{
|
|
ItemPrefab.DOFade(alph, 0.5f);
|
|
Label.DOFade(alph, 0.5f);
|
|
Icon.gameObject.SetActive(alph == 1);
|
|
}
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
AudioKit.StopVoice();
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
SetItem(0);
|
|
loader.Recycle2Cache();
|
|
}
|
|
}
|
|
}
|