using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class HudUI : UIHudBase { private static Queue _msgHintQueue = new Queue(); private NotificationPopupUI _hintPannel; private bool _isHintShowing = false; private void Awake() { _hintPannel = transform.Find("PopupNotification").GetComponent(); _hintPannel.GetComponent().alpha = 0; _msgHintQueue.Clear(); } private void OnEnable() { EventManager.Instance.AddEventListener(YogaEventType.ShowHint, PushHint); } private void OnDisable() { EventManager.Instance.RemoveEventListener(YogaEventType.ShowHint, PushHint); } private void PushHint(object[] args) { var msg = new Msg(); if (args.Length < 2) throw new Exception("²خت‎´يخَ"); msg.Title = args[0].ToString(); msg.Content = args[1].ToString(); _msgHintQueue.Enqueue(msg); } public override void Init(object[] pageData) { base.Init(pageData); } private void Update() { if (_msgHintQueue.Count > 0 && !_isHintShowing) { var msg = _msgHintQueue.Dequeue(); StartCoroutine(ShowHint(msg)); } } private IEnumerator ShowHint(Msg msg) { _isHintShowing = true; yield return _hintPannel.Show(msg.Title, msg.Content); _isHintShowing = false; } } internal class Msg { public string Title { get; set; } public string Content { get; set; } }