using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class StudyTips : MonoBehaviour { public List Tips = new List(); /// /// 内容文本 /// public TextMeshProUGUI contenttext; /// /// 上一步 /// public Button Up; /// /// 下一步 /// public Button Down; private int index = 0; void Start() { contenttext.text = Tips[index]; Up.onClick.AddListener(() => { index--; if (index == 0) { index = 0; Up.gameObject.SetActive(false); } if (index >= 0) { Down.gameObject.SetActive(true); contenttext.text = Tips[index]; } }); Down.onClick.AddListener(() => { index++; if (index < Tips.Count) { Debug.Log(index); Up.gameObject.SetActive(true); contenttext.text = Tips[index]; } if (index >= Tips.Count-1) { Down.gameObject.SetActive(false); index = Tips.Count - 1; } }); } }