From a4375643fe475bac8f8682c69a2d2138b3048541 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 17 九月 2025 15:10:29 +0800
Subject: [PATCH] 0312 修改字体大小
---
Assets/Editor/Tool/ChangePrefabsFontSize.cs | 91 +++++++++++++++++++++++++++++++++++++++++++++
Assets/Editor/Tool/ChangePrefabsFontSize.cs.meta | 11 +++++
2 files changed, 102 insertions(+), 0 deletions(-)
diff --git a/Assets/Editor/Tool/ChangePrefabsFontSize.cs b/Assets/Editor/Tool/ChangePrefabsFontSize.cs
new file mode 100644
index 0000000..035b020
--- /dev/null
+++ b/Assets/Editor/Tool/ChangePrefabsFontSize.cs
@@ -0,0 +1,91 @@
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+using System.IO;
+using UnityEngine.UI;
+
+//鏍规嵁椤圭洰褰撲笅鎯呭喌璋冩暣锛岃皑鎱庝娇鐢�
+public class ChangePrefabsFontSize : EditorWindow {
+
+
+ [MenuItem("绛栧垝宸ュ叿/鏇存敼瀛椾綋澶у皬锛堟厧鐢級")]
+ public static void Open()
+ {
+ EditorWindow.GetWindow(typeof(ChangePrefabsFontSize));
+ }
+
+
+ void OnGUI()
+ {
+ GUILayout.Label("瀛椾綋");
+ if (GUILayout.Button("鏇存崲瀛椾綋澶у皬锛氱粺涓�+2"))
+ {
+ Change();
+ }
+ }
+
+ public static void Change()
+ {
+
+ string topFilePath=Application.dataPath + "/ResourcesOut/UI";
+
+
+ string[] filepaths1 = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
+ topFilePath = Application.dataPath + "/ResourcesOut/BuiltIn";
+ string[] filepaths2 = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
+ topFilePath = Application.dataPath + "/ResourcesOut/UIComp";
+ string[] filepaths3 = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
+
+ string[] filepaths = new string[filepaths1.Length + filepaths2.Length + filepaths3.Length];
+
+ filepaths1.CopyTo(filepaths, 0);
+ filepaths2.CopyTo(filepaths, filepaths1.Length);
+ filepaths3.CopyTo(filepaths, filepaths1.Length + filepaths2.Length);
+ Debug.LogFormat("棰勪慨鏀归鍒朵綋瀛椾綋鎬绘暟锛歿0}", filepaths.Length);
+ int startIndex = 0; //鏂囦欢鎵ц涓暟
+
+ int a = 0; // 鎬诲瓧浣撴暟
+ int i = 0; // 鏇存崲瀛椾綋鏁�
+ EditorApplication.update = delegate () {
+ string file = filepaths[startIndex];
+ file = file.Substring(file.IndexOf("Assets"));
+ bool isCancel = EditorUtility.DisplayCancelableProgressBar("棰勫埗浣撴枃瀛�-"+filepaths.Length, file, (float)startIndex / (float)filepaths.Length);
+ GameObject _prefab = AssetDatabase.LoadAssetAtPath<GameObject>(file);
+
+ Text[] transArr14 = _prefab.GetComponentsInChildren<Text>(true);
+ a += transArr14.Length;
+
+ bool change = false;
+ foreach (Text item in transArr14)
+ {
+ if (item.fontSize <= 30)
+ {
+ item.fontSize = item.fontSize + 2;
+ change = true;
+ }
+
+ }
+ if (change)
+ {
+ EditorUtility.SetDirty(_prefab);
+ Debug.LogFormat("鐣岄潰 {0} 瀛椾綋澶у皬淇敼鎴愬姛", file);
+ i++;
+ }
+
+ startIndex++;
+
+ if (isCancel || startIndex >= filepaths.Length) {
+ Debug.LogFormat("瀛椾綋鎵归噺淇敼鎴愬姛--妫�绱0}涓鍒朵綋, 瀛椾綋鎬讳釜鏁皗1}锛屼慨鏀箋2}", startIndex, a, i);
+ EditorUtility.ClearProgressBar();
+ EditorApplication.update = null;
+ startIndex = 0;
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ }
+ };
+ }
+
+
+
+}
diff --git a/Assets/Editor/Tool/ChangePrefabsFontSize.cs.meta b/Assets/Editor/Tool/ChangePrefabsFontSize.cs.meta
new file mode 100644
index 0000000..ac6b4af
--- /dev/null
+++ b/Assets/Editor/Tool/ChangePrefabsFontSize.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: cd63fb92f9d7fe24892a18a1b780424b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
Gitblit v1.8.0