using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Random = UnityEngine.Random; namespace Script.UI { public class ScrollItem : MonoBehaviour { public Text txtNum; private List _list = new List(); private int index = 0; public float time; private WaitForSeconds _waitForSeconds; private void OnEnable() { _list = ExcelManager.Instance.GetAllPlayerID; _waitForSeconds = new WaitForSeconds(time); StartCoroutine(Upd()); } private void OnDisable() { StopCoroutine(Upd()); } IEnumerator Upd() { yield return null; while (true) { yield return _waitForSeconds; ++index; if (index >= _list.Count - 1) { index = 0; } txtNum.text = _list[index]; } } public void ShowOrHide(bool isShow) { gameObject.SetActive(isShow); } } }