using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using UnityEngine; using Debug = UnityEngine.Debug; public class RichText : MonoBehaviour { [Header("文本预制体")] public GameObject textItem; private string text = ""; public string Text { [DebuggerStepThrough] get => text; [DebuggerStepThrough] set { text = value; Debug.Log("===------"); Debug.Log("
" + text + "
"); foreach (string item in SplitStringByTags("" + text + "
", 23)) { GameObject gameObject = Instantiate(textItem, GameObject.Find(name).transform); gameObject.GetComponent标签以及其中的内容 var regex = new System.Text.RegularExpressions.Regex(@"
(.*?)
"); var matches = regex.Matches(input); // 用于存储结果 var resultList = new System.Collections.Generic.List和
之间的内容 if (line.Length > maxLength) { // 如果行的长度大于maxLength,则拆分成多个子字符串 for (int i = 0; i < line.Length; i += maxLength) { int length = Math.Min(maxLength, line.Length - i); resultList.Add(line.Substring(i, length)); } } else { resultList.Add(line); } } return resultList.ToArray(); } // Update is called once per frame void Update() { } }