using UnityEngine; using UnityEditor; using UnityEngine.UI; public class IncreaseTextFontSize : MonoBehaviour { [MenuItem("Tools/Text字体工具/字体大小+2")] private static void IncreaseFontSize() { int count = 0; Text[] texts = GameObject.FindObjectsOfType(true); // true表示包括未激活对象 foreach (Text text in texts) { Undo.RecordObject(text, "Increase Font Size"); text.fontSize += 2; EditorUtility.SetDirty(text); count++; } Debug.Log($"已更新 {count} 个 Text 字体大小 +2"); } }