using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; using static System.Net.Mime.MediaTypeNames; public class TipMangner : MonoBehaviour { /// /// 存放的字 /// public List tips = new List(); /// /// 显示的文本内容 /// public TextMeshProUGUI text; /// /// 下一个按钮 /// public Button Next_BTn; /// /// 上一个按钮 /// public Button Prev_BTn; private int index = 0; // Start is called before the first frame update void Start() { text.text = tips[0]; Next_BTn.onClick.AddListener(() => { Next(); }); Prev_BTn.onClick.AddListener(() => { Prev(); }); } /// /// 上一步按钮 /// public void Prev() { index--; if (index == 0) { index = 0; Prev_BTn.gameObject.SetActive(false); } if (index >= 0) { Next_BTn.gameObject.SetActive(true); text.text = tips[index]; } } /// /// 下一步按钮 /// public void Next() { index++; if (index < tips.Count) { Debug.Log(index); Prev_BTn.gameObject.SetActive(true); text.text = tips[index]; } if (index >= tips.Count - 1) { Next_BTn.gameObject.SetActive(false); index = tips.Count - 1; } } }