forked from zxl/LaboratoryProtection
70 lines
1.4 KiB
C#
70 lines
1.4 KiB
C#
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using PMaker.Extension;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public partial class UILeftTip : BaseBehaviour
|
|
{
|
|
[SerializeField]
|
|
private ScrollRect _scrollRect;
|
|
[SerializeField]
|
|
private GameObject[] _tips;
|
|
|
|
private void Reset()
|
|
{
|
|
this._scrollRect = this.GetComponentInChildren<ScrollRect>(true);
|
|
var list = this._scrollRect.content.Children().Select(_ => _.gameObject).ToList();
|
|
var first = this.transform.Find("firstTip").gameObject;
|
|
list.Insert(0, first);
|
|
this._tips = list.ToArray();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
foreach (var item in _tips)
|
|
{
|
|
item.SetActive(false);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ShowNext()
|
|
{
|
|
var next = _tips.FirstOrDefault(_ => _.activeSelf == false);
|
|
next?.gameObject.SetActive(true);
|
|
Canvas.ForceUpdateCanvases();
|
|
//await UniTask.Yield(this.GetCancellationTokenOnDestroy());
|
|
this._scrollRect.verticalNormalizedPosition = 0;
|
|
}
|
|
|
|
[Button]
|
|
public void HideAllTip()
|
|
{
|
|
foreach (var item in _tips)
|
|
{
|
|
item.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public partial class UILeftTip
|
|
{
|
|
[Button]
|
|
private void ShowAllTip()
|
|
{
|
|
foreach (var item in _tips)
|
|
{
|
|
item.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
#endif
|