using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class StudyTips : MonoBehaviour { public List<string> Tips = new List<string>(); /// <summary> /// ÄÚÈÝÎı¾ /// </summary> public TextMeshProUGUI contenttext; /// <summary> /// ÉÏÒ»²½ /// </summary> public Button Up; /// <summary> /// ÏÂÒ»²½ /// </summary> 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; } }); } }