123456789101112131415161718192021222324252627282930313233343536 |
- using UnityEngine;
- using UnityEditor;
- using TMPro;
- using System.IO;
- public static class PrefabTMPProBold
- {
- [MenuItem("Çл»/Scene_TextForTMP/Ô¤ÖÆÌåTMP¼Ó´Ö", false)]
- public static void ChangeText()
- {
- StartChangeScripts();
- }
- private static void StartChangeScripts()
- {
- string[] prefabs = Directory.GetFiles("Assets", "*.prefab", SearchOption.AllDirectories);
- for (int i = 0; i < prefabs.Length; i++)
- {
- GameObject go = AssetDatabase.LoadAssetAtPath(prefabs[i], typeof(System.Object)) as GameObject;
- TextMeshProUGUI[] textList = go.GetComponentsInChildren<TextMeshProUGUI>();
- if (textList.Length > 0)
- {
- GameObject root = PrefabUtility.LoadPrefabContents(prefabs[i]);
- if (root)
- {
- TextMeshProUGUI[] list = root.GetComponentsInChildren<TextMeshProUGUI>(true);
- for (int j = 0; j < list.Length; j++)
- {
- list[j].fontStyle = FontStyles.Bold;
- }
- }
- PrefabUtility.SaveAsPrefabAsset(root, prefabs[i], out bool success);
- }
- }
- }
- }
|