using UnityEngine; using UnityEngine.UI; using QFramework; using DG.Tweening; using System.Runtime.CompilerServices; 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); } 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(), false); } }); loader.LoadAsync(); } } public void SetItem(float alph) { ItemPrefab.DOFade(alph, 0.5f); Label.DOFade(alph, 0.5f); } protected override void OnShow() { } protected override void OnHide() { AudioKit.StopVoice(); } protected override void OnClose() { SetItem(0); loader.Recycle2Cache(); } } }