IncreaseTextFontSize.cs 601 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEngine.UI;
  4. public class IncreaseTextFontSize : MonoBehaviour
  5. {
  6. [MenuItem("Tools/Text字体工具/字体大小+2")]
  7. private static void IncreaseFontSize()
  8. {
  9. int count = 0;
  10. Text[] texts = GameObject.FindObjectsOfType<Text>(true); // true表示包括未激活对象
  11. foreach (Text text in texts)
  12. {
  13. Undo.RecordObject(text, "Increase Font Size");
  14. text.fontSize += 2;
  15. EditorUtility.SetDirty(text);
  16. count++;
  17. }
  18. Debug.Log($"已更新 {count} 个 Text 字体大小 +2");
  19. }
  20. }