forked from zxl/LaboratoryProtection
36 lines
804 B
C#
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
|
|
}
|