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; IAction curAction; protected override void OnInit(IUIData uiData = null) { mData = uiData as UIHintData ?? new UIHintData(); SetItem(0); TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) { //Debug.Log("²½ÖèÇл»£¿£¿£¿"); //Hide(); } protected override void OnOpen(IUIData uiData = null) { TypeEventSystem.Global.Register(OnStepChanged).UnRegisterWhenDisabled(gameObject); mData = uiData as UIHintData ?? new UIHintData(); if (curAction != null) { curAction.Deinit(); curAction = null; } Icon.gameObject.SetActive(mData.isShowIcon); Label.text = mData.txt; SetItem(1); if (mData.time != -1) { curAction = ActionKit.Delay(mData.time, () => { SetItem(0); }); curAction.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); Icon.gameObject.SetActive(alph == 1); } protected override void OnShow() { } protected override void OnHide() { AudioKit.StopVoice(); } protected override void OnClose() { SetItem(0); loader.Recycle2Cache(); } } }