94 lines
3.3 KiB
C#
94 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using UnityEngine.UI;
|
|
using UnityEditor.VersionControl;
|
|
|
|
public static class ChangeTextFont
|
|
{
|
|
private static string[] MyFolders = new string[] {
|
|
//"Assets/ztest",
|
|
//"Assets/ManagedResources/Prefabs/UI",
|
|
//"Assets/ManagedResources/UpdatePanel",
|
|
"Assets/ManagedResources/Prefabs/Effect",
|
|
"Assets/ManagedResources/Prefabs/Map",
|
|
};
|
|
[MenuItem("MyTools/ChangeScriptComponents")]
|
|
public static void ChangeScriptComponents()
|
|
{
|
|
Font a = AssetDatabase.LoadAssetAtPath<Font>("Assets/ManagedResources/Fonts/HY-Sayeez/HY-Sayeez.otf");
|
|
if (a != null)
|
|
{
|
|
Debug.Log(a.name);
|
|
}
|
|
string[] guids = AssetDatabase.FindAssets("t:Prefab", MyFolders);
|
|
for (int i = 0; i < guids.Length; ++i)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
|
GameObject prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
|
|
var srcA = prefab.GetComponentsInChildren<Text>();
|
|
if (srcA != null && srcA.Length > 0)
|
|
{
|
|
foreach (var item in srcA)
|
|
{
|
|
item.font = a;
|
|
}
|
|
PrefabUtility.SavePrefabAsset(prefab);
|
|
}
|
|
}
|
|
AssetDatabase.SaveAssets();
|
|
}
|
|
[MenuItem("MyTools/ChangeTextFontSize")]
|
|
public static void ChangeTextFontSize()
|
|
{
|
|
Font a = AssetDatabase.LoadAssetAtPath<Font>("Assets/ManagedResources/Fonts/HY-Sayeez/HY-Sayeez.otf");
|
|
if (a != null)
|
|
{
|
|
Debug.Log(a.name);
|
|
}
|
|
string[] guids = AssetDatabase.FindAssets("t:Prefab", MyFolders);
|
|
for (int i = 0; i < guids.Length; ++i)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
|
GameObject prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
|
|
var srcA = prefab.GetComponentsInChildren<Text>();
|
|
if (srcA != null && srcA.Length > 0)
|
|
{
|
|
foreach (var item in srcA)
|
|
{
|
|
if (item.fontSize > 50)
|
|
{
|
|
item.fontSize = (int)(item.fontSize * 0.9f);
|
|
}
|
|
}
|
|
PrefabUtility.SavePrefabAsset(prefab);
|
|
}
|
|
}
|
|
AssetDatabase.SaveAssets();
|
|
}
|
|
[MenuItem("MyTools/ChangeTextSpacing")]
|
|
public static void ChangeTextSpacing()
|
|
{
|
|
string[] guids = AssetDatabase.FindAssets("t:Prefab", MyFolders);
|
|
for (int i = 0; i < guids.Length; ++i)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
|
GameObject prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
|
|
var srcA = prefab.GetComponentsInChildren<TextSpacing>();
|
|
if (srcA != null && srcA.Length > 0)
|
|
{
|
|
foreach (var item in srcA)
|
|
{
|
|
if (item._textSpacing < -3)
|
|
{
|
|
item._textSpacing = -3;
|
|
}
|
|
}
|
|
PrefabUtility.SavePrefabAsset(prefab);
|
|
}
|
|
}
|
|
AssetDatabase.SaveAssets();
|
|
}
|
|
}
|