From 6ab4f430f523d7a85589c7eef9523f6fa6c48aea Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 11 十二月 2020 20:31:55 +0800
Subject: [PATCH] 0312 更新批量文字工具
---
Assets/Editor/Tool/ChangePrefabsFont.cs.meta | 11 +++
/dev/null | 8 --
Assets/Editor/Tool/ImportPrefabsWords.cs | 15 ++++-
Assets/Editor/Tool/ChangePrefabsFont.cs | 98 ++++++++++++++++++++++++++++++++
Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs | 2
5 files changed, 122 insertions(+), 12 deletions(-)
diff --git a/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs
index f81a9e3..caaf52d 100644
--- a/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs
+++ b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs
@@ -17,6 +17,6 @@
private void Reload()
{
- (target as SecondFrameLoader).Reload();
+ //(target as SecondFrameLoader).Reload();
}
}
diff --git a/Assets/Editor/Tool/ChangePrefabsFont.cs b/Assets/Editor/Tool/ChangePrefabsFont.cs
new file mode 100644
index 0000000..1d46393
--- /dev/null
+++ b/Assets/Editor/Tool/ChangePrefabsFont.cs
@@ -0,0 +1,98 @@
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+using System.IO;
+using UnityEngine.UI;
+using Snxxz.UI;
+
+
+public class ChangePrefabsFont : EditorWindow {
+
+
+ [MenuItem("绛栧垝宸ュ叿/鏇存崲瀛椾綋")]
+ public static void Open()
+ {
+ EditorWindow.GetWindow(typeof(ChangePrefabsFont));
+ }
+
+ Font toChange;
+ static Font toChangeFont;
+
+ Font fromFont;
+ static Font fromChangeFont;
+ void OnGUI()
+ {
+ GUILayout.Label("鍘熷瓧浣�");
+ fromFont = (Font)EditorGUILayout.ObjectField(fromFont, typeof(Font), true, GUILayout.MinWidth(100f));
+ fromChangeFont = fromFont;
+ GUILayout.Label("鏇挎崲瀛椾綋");
+ toChange = (Font)EditorGUILayout.ObjectField(toChange, typeof(Font), true, GUILayout.MinWidth(100f));
+ toChangeFont = toChange;
+ if (GUILayout.Button("鏇存崲"))
+ {
+ Change();
+ }
+ }
+
+ public static void Change()
+ {
+
+ //杩欎釜寰堥噸瑕侊紝鍗氫富鍙戠幇濡傛灉娌℃湁杩欎釜浠g爜锛寀nity鏄笉浼氬療瑙夊埌缂栬緫鍣ㄦ湁鏀瑰姩鐨勶紝鑷劧璁剧疆瀹屽悗鐩存帴鍒囨崲鍦烘櫙鏀瑰彉鏄笉琚繚瀛�
+ //鐨� 濡傛灉涓嶅姞杩欎釜浠g爜 鍦ㄥ仛瀹屾洿鏀瑰悗 鑷繁闅忎究鎵嬪姩淇敼涓嬪満鏅噷鐗╀綋鐨勭姸鎬� 鍦ㄤ繚瀛樺氨濂戒簡
+ //Undo.RecordObject(t, t.gameObject.name);
+ //t.font = toChangeFont;
+ 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);
+
+
+ string[] filepaths = new string[filepaths1.Length + filepaths2.Length];
+
+ filepaths1.CopyTo(filepaths, 0);
+ filepaths2.CopyTo(filepaths, filepaths1.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;
+
+ foreach (Text item in transArr14)
+ {
+
+ // /Debug.LogFormat("{0}鍖呭惈鏂囧瓧 {1}-{2}", file, item.name, item.text);
+ if (item.font == fromChangeFont)
+ {
+ item.font = toChangeFont;
+ EditorUtility.SetDirty(_prefab);
+ i++;
+ }
+
+ }
+ startIndex++;
+
+ if (isCancel || startIndex >= filepaths.Length) {
+ EditorUtility.ClearProgressBar();
+ EditorApplication.update = null;
+ startIndex = 0;
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ Debug.LogFormat("瀛椾綋鎵归噺淇敼鎴愬姛--{0}", i);
+ }
+ };
+ }
+
+
+
+}
diff --git a/Assets/Editor/Tool/ChangePrefabsFont.cs.meta b/Assets/Editor/Tool/ChangePrefabsFont.cs.meta
new file mode 100644
index 0000000..6f48145
--- /dev/null
+++ b/Assets/Editor/Tool/ChangePrefabsFont.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 90b64cc7949e75542ba2ec380e016e14
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Editor/Tool/ImportPrefabsWords.cs b/Assets/Editor/Tool/ImportPrefabsWords.cs
index fa3ea42..b0590b9 100644
--- a/Assets/Editor/Tool/ImportPrefabsWords.cs
+++ b/Assets/Editor/Tool/ImportPrefabsWords.cs
@@ -27,6 +27,7 @@
string[] lines = File.ReadAllLines(writePath, Encoding.UTF8);
int startIndex = 0;
+ int changeCnt = 0;
EditorApplication.update = delegate () {
string[] info = lines[startIndex].Split('\t');
startIndex++;
@@ -66,9 +67,16 @@
Text item = transArr[index];
if (item.name == name)
{
- item.text = content;
- EditorUtility.SetDirty(_prefab);
- }else
+ if (item.text != content)
+ {
+ item.text = content;
+ item.fontSize = item.fontSize - 2;
+ EditorUtility.SetDirty(_prefab);
+ changeCnt++;
+ //Debug.LogFormat("瀛椾綋鎵归噺鏂囦欢--{0} , {1}", file, index);
+ }
+ }
+ else
{
Debug.LogErrorFormat("绗瑊0}琛屾浛鎹㈠け璐1}锛寋2}", startIndex+1, file, name);
}
@@ -81,6 +89,7 @@
startIndex = 0;
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
+ Debug.LogFormat("瀛椾綋鎵归噺淇敼鎴愬姛--{0}", changeCnt);
}
};
diff --git a/Assets/XLua/Src/Editor/LuaIde.meta b/Assets/XLua/Src/Editor/LuaIde.meta
deleted file mode 100644
index 916ddd7..0000000
--- a/Assets/XLua/Src/Editor/LuaIde.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: eaaa05bf5dd661e4fa2dba51ccbc1f3a
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
--
Gitblit v1.8.0