1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/EditorUITool/Scripts/TMPRichTextHelper.cs

36 lines
804 B
C#

using PMaker.Extension;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
public class TMPRichTextHelper : MonoBehaviour
{
#if UNITY_EDITOR
public string current = "\"red\"";
public Color color;
public TextMeshProUGUI[] allText;
private void Reset()
{
this.allText = this.GetComponentsInChildren<TextMeshProUGUI>(true);
}
[Button]
public void ChangeColor()
{
var str = "#" + ColorUtility.ToHtmlStringRGB(color);
Debug.Log(str);
foreach (var item in allText)
{
Debug.Log(item.richText);
Debug.Log(item.text.Contains(this.current));
item.text = item.text.Replace(this.current, str);
Debug.Log(item.richText);
item.SetDirty();
}
}
#endif
}