2024-11-21 09:35:48 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class TextItem : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _textMeshPro;
|
|
|
|
|
|
|
|
|
|
[SerializeField] private List<string> textList = new List<string>();
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
textList.Clear();
|
2024-11-26 15:44:50 +08:00
|
|
|
|
_textMeshPro.text = "";
|
2024-11-21 09:35:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveOnText(int id)
|
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
|
BoxDebug.Log("文本id:"+id);
|
2024-11-21 09:35:48 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|