2024-11-26 15:44:50 +08:00

48 lines
1006 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
_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;
}
}