using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class TextItem : MonoBehaviour { [SerializeField] private TextMeshProUGUI _textMeshPro; [SerializeField] private List textList = new List(); // Start is called before the first frame update void Start() { } private void OnEnable() { textList.Clear(); _textMeshPro.text = ""; } // Update is called once per frame void Update() { } public void SaveOnText(int id) { BoxDebug.Log("文本id:"+id); var data = JsonTab.Instance.tables.DisplayTxt.Get(id); textList.Add(data.Text); if (textList.Count>5) { textList.Remove(textList[0]); } string content = ""; for (int i = 0; i < textList.Count; i++) { content += textList[i] + "\n"; } _textMeshPro.text = content; } }