|
@@ -18,10 +18,29 @@ namespace labelUtility
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
[Serializable]
|
|
[Serializable]
|
|
|
|
+ public class RegistTarget
|
|
|
|
+ {
|
|
|
|
+ public string Name;
|
|
|
|
+ public bool Force;
|
|
|
|
+ public bool Ignore;
|
|
|
|
+ public Transform Transform;
|
|
|
|
+ public ComponentType Type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Serializable]
|
|
|
|
+ public class ComponentEventString
|
|
|
|
+ {
|
|
|
|
+ public ComponentType ComponentType;
|
|
|
|
+ public List<string> Strings;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Serializable]
|
|
public class LabelSet //todo 更新
|
|
public class LabelSet //todo 更新
|
|
{
|
|
{
|
|
public string Name;
|
|
public string Name;
|
|
|
|
|
|
|
|
+ public UtilityType UtilityType;
|
|
|
|
+
|
|
public string LabelScriptPath;
|
|
public string LabelScriptPath;
|
|
public string LabelScriptName;
|
|
public string LabelScriptName;
|
|
public string LabePrefix = "public static string";
|
|
public string LabePrefix = "public static string";
|
|
@@ -29,10 +48,10 @@ namespace labelUtility
|
|
|
|
|
|
public string ComponentScriptPath;
|
|
public string ComponentScriptPath;
|
|
public string ComponentScriptName;
|
|
public string ComponentScriptName;
|
|
|
|
+ public string DerivedString;
|
|
|
|
+ public string RegistMethodString;
|
|
public string ComponentPrefix = "private";
|
|
public string ComponentPrefix = "private";
|
|
public string NameExcludeString;
|
|
public string NameExcludeString;
|
|
- //public string RegistPrefix;
|
|
|
|
- //public string RegistSuffix;
|
|
|
|
public string RegistString;
|
|
public string RegistString;
|
|
public List<string> RegistExtraLines;
|
|
public List<string> RegistExtraLines;
|
|
public TextAsset ComponentScript;
|
|
public TextAsset ComponentScript;
|
|
@@ -42,11 +61,14 @@ namespace labelUtility
|
|
|
|
|
|
public bool FoldOut;
|
|
public bool FoldOut;
|
|
public float TotalHeight;
|
|
public float TotalHeight;
|
|
- public List<ComponentPurview> ComponentPurviews = new List<ComponentPurview>();
|
|
|
|
|
|
+ public List<ComponentType> RegistTypes = new List<ComponentType>();
|
|
|
|
+ public List<RegistTarget> RegistTargets = new List<RegistTarget>();
|
|
}
|
|
}
|
|
|
|
|
|
- public enum ComponentPurview //todo 更新
|
|
|
|
|
|
+ [Serializable]
|
|
|
|
+ public enum ComponentType //todo 更新
|
|
{
|
|
{
|
|
|
|
+ None,
|
|
Text,
|
|
Text,
|
|
Slider,
|
|
Slider,
|
|
Image,
|
|
Image,
|
|
@@ -58,41 +80,126 @@ namespace labelUtility
|
|
VirtualScrollRectPlus,
|
|
VirtualScrollRectPlus,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public enum UtilityType
|
|
|
|
+ {
|
|
|
|
+ XmlLabel,
|
|
|
|
+ PrefabLabel,
|
|
|
|
+ Regist,
|
|
|
|
+ }
|
|
|
|
+
|
|
public class LabelUtility : MonoBehaviour
|
|
public class LabelUtility : MonoBehaviour
|
|
{
|
|
{
|
|
#region Config
|
|
#region Config
|
|
|
|
|
|
|
|
+ public List<string> DllNames;
|
|
|
|
+ public List<ComponentEventString> EventStrings;
|
|
public List<LabelSet> LabelSets;
|
|
public List<LabelSet> LabelSets;
|
|
|
|
|
|
public static string StartMark = "//StartMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string StartMark = "//StartMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string EndMark = "//EndMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string EndMark = "//EndMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string RegistStartMark = "//RegistStartMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string RegistStartMark = "//RegistStartMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string RegistEndMark = "//RegistEndMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string RegistEndMark = "//RegistEndMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
|
|
+ public static string EventStartMark = "//EventStartMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
|
|
+ public static string EventEndMark = "//EventEndMark-Used by LabelUtility-Do not remove"; //todo 更新
|
|
public static string Prefix = "public static string ";
|
|
public static string Prefix = "public static string ";
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- public static void CreateLabelScript(LabelSet labelSet)
|
|
|
|
|
|
+ public static void CreateLabelScript(LabelSet labelSet, bool showWarning = true, bool auto = false)
|
|
{
|
|
{
|
|
- if (!EditorUtility.DisplayDialog("注意", "新建LabelScript?", "确定", "取消"))
|
|
|
|
|
|
+ if (showWarning)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ if (!EditorUtility.DisplayDialog("注意", "新建LabelScript?", "确定", "取消"))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!auto)
|
|
|
|
+ {
|
|
|
|
+ auto = EditorUtility.DisplayDialog("提示", "是否自动提取标签", "确定", "取消");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string scriptContent = "";
|
|
|
|
+ foreach (var dllName in InstanceManager.SearchInstance<LabelUtility>().DllNames)
|
|
|
|
+ {
|
|
|
|
+ scriptContent += $"using {dllName};\r\n";
|
|
}
|
|
}
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ scriptContent += $"public class {labelSet.LabelScriptName}";
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ scriptContent += $"{{\r\n\t#region Config\r\n\r\n\t{StartMark}\r\n\t{EndMark}\r\n\r\n\t#endregion\r\n}}";
|
|
|
|
+
|
|
|
|
+ labelSet.LabelScript = CreateScript(labelSet.LabelScriptName, labelSet.LabelScriptPath, scriptContent);
|
|
|
|
|
|
- labelSet.LabelScript = CreateScript(labelSet.LabelScriptName, labelSet.LabelScriptPath);
|
|
|
|
|
|
+ if (auto)
|
|
|
|
+ {
|
|
|
|
+ if (labelSet.UtilityType == UtilityType.XmlLabel)
|
|
|
|
+ {
|
|
|
|
+ CreateLabelFromLanguageXml(labelSet, false);
|
|
|
|
+ }
|
|
|
|
+ else if (labelSet.UtilityType == UtilityType.Regist || labelSet.UtilityType == UtilityType.PrefabLabel)
|
|
|
|
+ {
|
|
|
|
+ CreateLabelFromPrefab(labelSet, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- public static void CreateComponentScript(LabelSet labelSet)
|
|
|
|
|
|
+ public static void CreateComponentScript(LabelSet labelSet, bool showWarning = true, bool regist = false)
|
|
{
|
|
{
|
|
- if (!EditorUtility.DisplayDialog("注意", "新建ComponentScript?", "确定", "取消"))
|
|
|
|
|
|
+ if (showWarning)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ if (!EditorUtility.DisplayDialog("注意", "新建ComponentScript?", "确定", "取消"))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!regist)
|
|
|
|
+ {
|
|
|
|
+ regist = EditorUtility.DisplayDialog("提示", "是否自动注册", "确定", "取消");
|
|
}
|
|
}
|
|
|
|
|
|
- labelSet.ComponentScript = CreateScript(labelSet.ComponentScriptName, labelSet.ComponentScriptPath);
|
|
|
|
|
|
+ string scriptContent = "";
|
|
|
|
+ foreach (var dllName in InstanceManager.SearchInstance<LabelUtility>().DllNames)
|
|
|
|
+ {
|
|
|
|
+ scriptContent += $"using {dllName};\r\n";
|
|
|
|
+ }
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ scriptContent += $"public class {labelSet.ComponentScriptName}";
|
|
|
|
+ if (string.IsNullOrEmpty(labelSet.DerivedString))
|
|
|
|
+ {
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ scriptContent += $" : {labelSet.DerivedString}\r\n";
|
|
|
|
+ }
|
|
|
|
+ scriptContent += $"{{\r\n\t#region Config\r\n\r\n\t{StartMark}\r\n\t{EndMark}\r\n\r\n\t#endregion\r\n";
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ if (!string.IsNullOrEmpty(labelSet.RegistMethodString))
|
|
|
|
+ {
|
|
|
|
+ scriptContent += $"\t{labelSet.RegistMethodString}\r\n\t{{\r\n";
|
|
|
|
+ scriptContent += $"\t\t{RegistStartMark}\r\n";
|
|
|
|
+ scriptContent += $"\t\t{RegistEndMark}\r\n";
|
|
|
|
+ scriptContent += $"\t}}\r\n";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ scriptContent += "\r\n";
|
|
|
|
+ scriptContent += $"\t{EventStartMark}\r\n";
|
|
|
|
+ scriptContent += $"\t{EventEndMark}\r\n";
|
|
|
|
+
|
|
|
|
+ scriptContent += $"}}";
|
|
|
|
+
|
|
|
|
+ labelSet.ComponentScript = CreateScript(labelSet.ComponentScriptName, labelSet.ComponentScriptPath, scriptContent);
|
|
|
|
+
|
|
|
|
+ if (regist)
|
|
|
|
+ {
|
|
|
|
+ CreateComponentsFromPrefab(labelSet, false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- private static TextAsset CreateScript(string scriptName, string scriptPath)
|
|
|
|
|
|
+ private static TextAsset CreateScript(string scriptName, string scriptPath, string content)
|
|
{
|
|
{
|
|
string directory = scriptPath.TrimEnd('/', '\\') + "/";
|
|
string directory = scriptPath.TrimEnd('/', '\\') + "/";
|
|
|
|
|
|
@@ -117,20 +224,28 @@ namespace labelUtility
|
|
throw new Exception($"已经存在一个 {fullPath}");
|
|
throw new Exception($"已经存在一个 {fullPath}");
|
|
}
|
|
}
|
|
|
|
|
|
- string scriptContent = $"public class {scriptName}\r\n{{\r\n\t#region Config\r\n\r\n\t{StartMark}\r\n\t{EndMark}\r\n\r\n\t#endregion\r\n}}";
|
|
|
|
- File.WriteAllText(fullPath, scriptContent);
|
|
|
|
|
|
+ File.WriteAllText(fullPath, content);
|
|
AssetDatabase.Refresh();
|
|
AssetDatabase.Refresh();
|
|
return AssetDatabase.LoadAssetAtPath<TextAsset>(fullPath);
|
|
return AssetDatabase.LoadAssetAtPath<TextAsset>(fullPath);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static void CreateLabelFromPrefab(LabelSet labelSet) //todo 更新
|
|
|
|
|
|
+ public static void CreateLabelFromPrefab(LabelSet labelSet, bool showWarning = true) //todo 更新
|
|
{
|
|
{
|
|
- if (!EditorUtility.DisplayDialog("注意", "重新生成Prefab Label?", "确定", "取消"))
|
|
|
|
|
|
+ if (labelSet.LabelScript == null)
|
|
{
|
|
{
|
|
|
|
+ Debug.LogError("LabelScript is null");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (showWarning)
|
|
|
|
+ {
|
|
|
|
+ if (!EditorUtility.DisplayDialog("注意", "重新生成Prefab Label?", "确定", "取消"))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
List<string> labels = new List<string>();
|
|
List<string> labels = new List<string>();
|
|
List<Transform> transforms = GetAllTransformFromPrefab(labelSet.Prefabs);
|
|
List<Transform> transforms = GetAllTransformFromPrefab(labelSet.Prefabs);
|
|
foreach (var transform in transforms)
|
|
foreach (var transform in transforms)
|
|
@@ -140,13 +255,22 @@ namespace labelUtility
|
|
InsertLineToScript(StartMark, EndMark, labelSet.LabelScript, labels);
|
|
InsertLineToScript(StartMark, EndMark, labelSet.LabelScript, labels);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void CreateLabelFromLanguageXml(LabelSet labelSet) //todo 更新
|
|
|
|
|
|
+ public static void CreateLabelFromLanguageXml(LabelSet labelSet, bool showWarning = true) //todo 更新
|
|
{
|
|
{
|
|
- if (!EditorUtility.DisplayDialog("注意", "重新生成LanguageXml Label?", "确定", "取消"))
|
|
|
|
|
|
+ if (labelSet.LabelScript == null)
|
|
{
|
|
{
|
|
|
|
+ Debug.LogError("LabelScript is null");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (showWarning)
|
|
|
|
+ {
|
|
|
|
+ if (!EditorUtility.DisplayDialog("注意", "重新生成LanguageXml Label?", "确定", "取消"))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
List<string> labels = new List<string>();
|
|
List<string> labels = new List<string>();
|
|
foreach (var language in labelSet.Languages)
|
|
foreach (var language in labelSet.Languages)
|
|
{
|
|
{
|
|
@@ -181,124 +305,123 @@ namespace labelUtility
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static void CreateComponentsFromPrefab(LabelSet labelSet) //todo 更新
|
|
|
|
|
|
+ public static Type GetType(ComponentType componentType)
|
|
{
|
|
{
|
|
- if (!EditorUtility.DisplayDialog("注意", "重新生成PrefabComponent?", "确定", "取消"))
|
|
|
|
|
|
+ Assembly assembly = Assembly.Load("UnityEngine.UI");
|
|
|
|
+ Type type = assembly.GetType($"UnityEngine.UI.{componentType}");
|
|
|
|
+ if (type == null)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ assembly = Assembly.Load("UnityEngine");
|
|
|
|
+ type = assembly.GetType($"UnityEngine.{componentType}");
|
|
}
|
|
}
|
|
-
|
|
|
|
- List <string> typeNames = new List<string>();
|
|
|
|
- foreach (var purview in labelSet.ComponentPurviews)
|
|
|
|
|
|
+ if (type == null)
|
|
{
|
|
{
|
|
- typeNames.Add(purview.ToString());
|
|
|
|
|
|
+ assembly = Assembly.Load("Assembly-CSharp");
|
|
|
|
+ type = assembly.GetType($"{componentType}");
|
|
}
|
|
}
|
|
- List <Transform> transforms = GetAllTransformFromPrefab(labelSet.Prefabs);
|
|
|
|
- Dictionary<string, List<string>> namesDictionary = new Dictionary<string, List<string>>();
|
|
|
|
- foreach (var name in typeNames)
|
|
|
|
|
|
+ return type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static void CreateComponentsFromPrefab(LabelSet labelSet, bool showWarning = true) //todo 更新
|
|
|
|
+ {
|
|
|
|
+ if (labelSet.ComponentScript == null)
|
|
{
|
|
{
|
|
- namesDictionary.Add(name, new List<string>());
|
|
|
|
|
|
+ Debug.LogError("ComponentScript is null");
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- foreach (var kv in namesDictionary)
|
|
|
|
|
|
+
|
|
|
|
+ if (showWarning)
|
|
{
|
|
{
|
|
- Assembly assembly = Assembly.Load("UnityEngine.UI");
|
|
|
|
- Type type = assembly.GetType($"UnityEngine.UI.{kv.Key}");
|
|
|
|
- //Debug.Log($"UnityEngine.UI.{kv.Key}");
|
|
|
|
- if (type == null)
|
|
|
|
- {
|
|
|
|
- assembly = Assembly.Load("UnityEngine");
|
|
|
|
- type = assembly.GetType($"UnityEngine.{kv.Key}");
|
|
|
|
- }
|
|
|
|
- if (type == null)
|
|
|
|
- {
|
|
|
|
- assembly = Assembly.Load("Assembly-CSharp");
|
|
|
|
- type = assembly.GetType($"{kv.Key}");
|
|
|
|
- }
|
|
|
|
- foreach (var transform in transforms)
|
|
|
|
|
|
+ if (!EditorUtility.DisplayDialog("注意", "重新生成PrefabComponent?", "确定", "取消"))
|
|
{
|
|
{
|
|
- if (transform.GetComponent(type) == null) continue;
|
|
|
|
- namesDictionary[kv.Key].Add(transform.name);
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- List<string> names = new List<string>();
|
|
|
|
- List<string> components = new List<string>();
|
|
|
|
|
|
+
|
|
|
|
+ List<string> defineStrings = new List<string>();
|
|
List<string> registStrings = new List<string>();
|
|
List<string> registStrings = new List<string>();
|
|
|
|
+ List<string> eventStrings = new List<string>();
|
|
registStrings.AddRange(labelSet.RegistExtraLines);
|
|
registStrings.AddRange(labelSet.RegistExtraLines);
|
|
- foreach (var kv in namesDictionary)
|
|
|
|
|
|
+ foreach (var registTarget in labelSet.RegistTargets)
|
|
{
|
|
{
|
|
- foreach (var name in kv.Value)
|
|
|
|
|
|
+ if (registTarget.Ignore) continue;
|
|
|
|
+ defineStrings.Add($"{labelSet.ComponentPrefix} {registTarget.Type} {registTarget.Transform.name};");
|
|
|
|
+ string registString = labelSet.RegistString.Replace("#NAME", registTarget.Transform.name).Replace("#TYPE", registTarget.Type.ToString()).Replace("#NEWNAME", registTarget.Name);
|
|
|
|
+ if (labelSet.LabelScript != null)
|
|
|
|
+ {
|
|
|
|
+ registString = registString.Replace("#LABEL", labelSet.LabelScript.name);
|
|
|
|
+ }
|
|
|
|
+ registStrings.Add(registString);
|
|
|
|
+
|
|
|
|
+ foreach (var eventString in InstanceManager.SearchInstance<LabelUtility>().EventStrings)
|
|
{
|
|
{
|
|
- names.Add(name);
|
|
|
|
- string newName = string.IsNullOrEmpty(labelSet.NameExcludeString) ? name : name.Replace(labelSet.NameExcludeString, "");
|
|
|
|
- components.Add($"{labelSet.ComponentPrefix} {kv.Key} {newName};");
|
|
|
|
- registStrings.Add(labelSet.RegistString.Replace("#NAME", name).Replace("#TYPE", kv.Key).Replace("#NEWNAME", newName));
|
|
|
|
|
|
+ if (eventString.ComponentType == registTarget.Type)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < eventString.Strings.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ eventStrings.Add($"{labelSet.ComponentPrefix} {eventString.Strings[i].Replace("#NEWNAME", registTarget.Name)}");
|
|
|
|
+ eventStrings.Add("{");
|
|
|
|
+ eventStrings.Add("}");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //for (int i = 0; i < names.Count; i++)
|
|
|
|
- //{
|
|
|
|
- // components.Add(names[i].Substring(names[i].IndexOf(' ') + 1));
|
|
|
|
- //}
|
|
|
|
- InsertLineToScript(StartMark, EndMark, labelSet.ComponentScript, components);
|
|
|
|
|
|
+ InsertLineToScript(StartMark, EndMark, labelSet.ComponentScript, defineStrings);
|
|
InsertLineToScript(RegistStartMark, RegistEndMark, labelSet.ComponentScript, registStrings);
|
|
InsertLineToScript(RegistStartMark, RegistEndMark, labelSet.ComponentScript, registStrings);
|
|
|
|
|
|
- //List<string> names = new List<string>();
|
|
|
|
- //List<string> textNames = new List<string>();
|
|
|
|
- //List<string> sliderNames = new List<string>();
|
|
|
|
- //List<string> imageNames = new List<string>();
|
|
|
|
- //List<string> buttonNames = new List<string>();
|
|
|
|
- //List<string> transformNames = new List<string>();
|
|
|
|
- //List<string> rectTransformNames = new List<string>();
|
|
|
|
- //List<string> spriteRendererNames = new List<string>();
|
|
|
|
- //List<Transform> transforms = GetAllTransformFromPrefab(labelSet.Prefabs);
|
|
|
|
- //foreach (var transform in transforms)
|
|
|
|
|
|
+ //List <string> typeNames = new List<string>();
|
|
|
|
+ //foreach (var purview in labelSet.RegistTypes)
|
|
//{
|
|
//{
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.Text) && transform.GetComponent<Text>() != null)
|
|
|
|
- // {
|
|
|
|
- // textNames.Add($"Text {transform.name}");
|
|
|
|
- // }
|
|
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.Slider) && transform.GetComponent<Slider>() != null)
|
|
|
|
- // {
|
|
|
|
- // sliderNames.Add($"Slider {transform.name}");
|
|
|
|
- // }
|
|
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.Image) && transform.GetComponent<Image>() != null)
|
|
|
|
- // {
|
|
|
|
- // sliderNames.Add($"Image {transform.name}");
|
|
|
|
- // }
|
|
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.Button) && transform.GetComponent<Button>() != null)
|
|
|
|
- // {
|
|
|
|
- // buttonNames.Add($"Button {transform.name}");
|
|
|
|
- // }
|
|
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.Transform) && transform.GetComponent<Transform>() != null)
|
|
|
|
|
|
+ // typeNames.Add(purview.ToString());
|
|
|
|
+ //}
|
|
|
|
+ //List <Transform> transforms = GetAllTransformFromPrefab(labelSet.Prefabs);
|
|
|
|
+ //Dictionary<string, List<string>> namesDictionary = new Dictionary<string, List<string>>();
|
|
|
|
+ //foreach (var name in typeNames)
|
|
|
|
+ //{
|
|
|
|
+ // namesDictionary.Add(name, new List<string>());
|
|
|
|
+ //}
|
|
|
|
+ //foreach (var kv in namesDictionary)
|
|
|
|
+ //{
|
|
|
|
+ // Assembly assembly = Assembly.Load("UnityEngine.UI");
|
|
|
|
+ // Type type = assembly.GetType($"UnityEngine.UI.{kv.Key}");
|
|
|
|
+ // if (type == null)
|
|
// {
|
|
// {
|
|
- // transformNames.Add($"Transform {transform.name}");
|
|
|
|
|
|
+ // assembly = Assembly.Load("UnityEngine");
|
|
|
|
+ // type = assembly.GetType($"UnityEngine.{kv.Key}");
|
|
// }
|
|
// }
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.RectTransform) && transform.GetComponent<RectTransform>() != null)
|
|
|
|
|
|
+ // if (type == null)
|
|
// {
|
|
// {
|
|
- // rectTransformNames.Add($"RectTransform {transform.name}");
|
|
|
|
|
|
+ // assembly = Assembly.Load("Assembly-CSharp");
|
|
|
|
+ // type = assembly.GetType($"{kv.Key}");
|
|
// }
|
|
// }
|
|
- // if (labelSet.ComponentPurviews.Contains(ComponentPurview.SpriteRenderer) && transform.GetComponent<SpriteRenderer>() != null)
|
|
|
|
|
|
+ // foreach (var transform in transforms)
|
|
// {
|
|
// {
|
|
- // spriteRendererNames.Add($"SpriteRenderer {transform.name}");
|
|
|
|
|
|
+ // if (transform.GetComponent(type) == null) continue;
|
|
|
|
+ // namesDictionary[kv.Key].Add(transform.name);
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
- //names.AddRange(textNames);
|
|
|
|
- //names.AddRange(sliderNames);
|
|
|
|
- //names.AddRange(imageNames);
|
|
|
|
- //names.AddRange(buttonNames);
|
|
|
|
- //names.AddRange(transformNames);
|
|
|
|
- //names.AddRange(rectTransformNames);
|
|
|
|
- //names.AddRange(spriteRendererNames);
|
|
|
|
|
|
+ //List<string> names = new List<string>();
|
|
//List<string> components = new List<string>();
|
|
//List<string> components = new List<string>();
|
|
- //for (int i = 0; i < names.Count; i++)
|
|
|
|
- //{
|
|
|
|
- // string name = string.IsNullOrEmpty(labelSet.NameExcludeString) ? names[i] : names[i].Replace(labelSet.NameExcludeString, "");
|
|
|
|
- // components.Add($"{labelSet.ComponentPrefix} {name};");
|
|
|
|
- //}
|
|
|
|
- //for (int i = 0; i < names.Count; i++)
|
|
|
|
|
|
+ //List<string> registStrings = new List<string>();
|
|
|
|
+ //registStrings.AddRange(labelSet.RegistExtraLines);
|
|
|
|
+ //foreach (var kv in namesDictionary)
|
|
//{
|
|
//{
|
|
- // components.Add(names[i].Substring(names[i].IndexOf(' ') + 1));
|
|
|
|
|
|
+ // foreach (var name in kv.Value)
|
|
|
|
+ // {
|
|
|
|
+ // names.Add(name);
|
|
|
|
+ // string newName = string.IsNullOrEmpty(labelSet.NameExcludeString) ? name : name.Replace(labelSet.NameExcludeString, "");
|
|
|
|
+ // components.Add($"{labelSet.ComponentPrefix} {kv.Key} {newName};");
|
|
|
|
+ // string registString = labelSet.RegistString.Replace("#NAME", name).Replace("#TYPE", kv.Key).Replace("#NEWNAME", newName);
|
|
|
|
+ // if (labelSet.LabelScript != null)
|
|
|
|
+ // {
|
|
|
|
+ // registString = registString.Replace("#LABEL", labelSet.LabelScript.name);
|
|
|
|
+ // }
|
|
|
|
+ // registStrings.Add(registString);
|
|
|
|
+ // }
|
|
//}
|
|
//}
|
|
- //InsertLineToScript(labelSet.ComponentScript, components);
|
|
|
|
|
|
+ //InsertLineToScript(StartMark, EndMark, labelSet.ComponentScript, components);
|
|
|
|
+ //InsertLineToScript(RegistStartMark, RegistEndMark, labelSet.ComponentScript, registStrings);
|
|
}
|
|
}
|
|
|
|
|
|
private static void InsertLineToScript(string startMark, string endMark, TextAsset textAsset, List<string> insertLines)
|
|
private static void InsertLineToScript(string startMark, string endMark, TextAsset textAsset, List<string> insertLines)
|