forked from zxl/LaboratoryProtection
56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
#if UNITY_EDITOR
|
|
using PMaker.Extension;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
public class FontHelper : BaseBehaviour
|
|
{
|
|
private void Reset()
|
|
{
|
|
this.name = ">" + this.GetType().Name;
|
|
this.gameObject.tag = "EditorOnly";
|
|
}
|
|
|
|
public TextMeshProUGUI[] allText;
|
|
|
|
public Dictionary<TMP_FontAsset, List<TextMeshProUGUI>> pool;
|
|
|
|
public TextMeshProUGUI text;
|
|
|
|
[Button]
|
|
public void Init()
|
|
{
|
|
this.allText = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
|
|
pool = new Dictionary<TMP_FontAsset, List<TextMeshProUGUI>>();
|
|
foreach (var item in this.allText)
|
|
{
|
|
var font = item.font;
|
|
if (pool.ContainsKey(font) != true)
|
|
{
|
|
pool.Add(font, new List<TextMeshProUGUI>());
|
|
}
|
|
pool[font].Add(item);
|
|
}
|
|
this.SetDirty();
|
|
}
|
|
|
|
[Button]
|
|
public void SetText()
|
|
{
|
|
var stringBuilder = new StringBuilder();
|
|
foreach (var item in allText)
|
|
{
|
|
stringBuilder.Append(item.text);
|
|
}
|
|
this.text.text = stringBuilder.ToString();
|
|
text.SetDirty();
|
|
}
|
|
}
|
|
#endif |