using System; using UnityEngine; using UnityEngine.UI; using DG.Tweening; using Assets.Scripts.UI.Control; using Assets.Scripts; public class MultiTips:PFUIText { private Text text; private Button button; private string[] tips { get; set; } private int currentIndex = 0; new void Awake() { base.Awake(); text = GetComponent(); var tiplist = ConfigHelper.mapApi.GetTipsList(); if (!string.IsNullOrEmpty(tiplist)) { tips = tiplist.Split('#'); } var random = new System.Random(); currentIndex = random.Next(0, tips.Length); SetText(); } // Start is called before the first frame update new void Start() { base.Awake(); } public void SetText() { if(text == null) { return; } if (currentIndex <= tips.Length) { text.text = tips[currentIndex]; if (currentIndex + 1 < tips.Length) { currentIndex++; } else { currentIndex = 0; } } } float time = 5f; // Update is called once per frame void Update() { time -= Time.deltaTime; while (time<0) { SetText(); time += 5f; } } }