| | |
| | | //-------------------------------------------------------- |
| | | //-------------------------------------------------------- |
| | | // [Author]: 玩个游戏 |
| | | // [ Date ]: Saturday, October 07, 2017 |
| | | //-------------------------------------------------------- |
| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | [SerializeField, Header("隐藏时间")] |
| | | float m_TipHideTime = 0.5f; |
| | | |
| | | bool isLoopRunning = false; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | |
| | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | ScrollTip.OnTipReceiveEvent -= OnTipReceiveEvent; |
| | | ScrollTip.OnTipReceiveEvent -= OnAddTipEvent; |
| | | ScrollTip.ReleaseAll(); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | ScrollTip.tipMoveTime = m_TipMoveTime; |
| | | ScrollTip.OnTipReceiveEvent += OnTipReceiveEvent; |
| | | ScrollTip.OnTipReceiveEvent += OnAddTipEvent; |
| | | mask.sizeDelta = mask.sizeDelta.SetY(tipDisplayCnt * m_TipHeight + (tipDisplayCnt - 1) * (m_TipDistance - m_TipHeight) + 10); |
| | | for (int i = 0; i < ScrollTip.m_Hints.Count; i++) |
| | | |
| | | // 如果有待处理的提示,立即启动循环 |
| | | if (ScrollTip.m_Hints.Count > 0) |
| | | { |
| | | LoopTipReceiveEvent().Forget(); |
| | | } |
| | | } |
| | | |
| | | async UniTask LoopTipReceiveEvent() |
| | | { |
| | | if (isLoopRunning) return; // 防止重复启动 |
| | | |
| | | isLoopRunning = true; |
| | | try |
| | | { |
| | | while (ScrollTip.m_Hints.Count > 0) |
| | | { |
| | | OnTipReceiveEvent(); |
| | | await UniTask.Delay(100); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | isLoopRunning = false; |
| | | } |
| | | } |
| | | |
| | | void OnAddTipEvent() |
| | | { |
| | | // 只有在没有循环运行时才启动新的循环 |
| | | if (!isLoopRunning) |
| | | { |
| | | LoopTipReceiveEvent().Forget(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (ScrollTip.m_ActiveTips.Count >= tipDisplayCnt) |
| | | { |
| | | ScrollTip.Release(ScrollTip.m_ActiveTips[0], false); |
| | | } |
| | | if (ScrollTip.m_ActiveTips.Count >= tipDisplayCnt) |
| | | { |
| | | ScrollTip.tipMoveTime = Time.deltaTime; |
| | | } |
| | | else |