diff --git a/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt b/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt new file mode 100644 index 0000000..cd63e0d --- /dev/null +++ b/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt @@ -0,0 +1,10 @@ +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace ZC +{ + [Procedure(ProcedureType.#CLASSNAME#)] + class #CLASSNAME# : ProcedureBase + { + } +} \ No newline at end of file diff --git a/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt.meta b/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt.meta new file mode 100644 index 0000000..08414f5 --- /dev/null +++ b/Assets/DemoGame/GameRes/ProcedureLogicTemplate.txt.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 91e9b42addbc4e5ea673fb5d36a7a685 +timeCreated: 1732263928 \ No newline at end of file diff --git a/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs b/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs new file mode 100644 index 0000000..d576632 --- /dev/null +++ b/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; +using TMPro; +using UnityEditor; +using UnityEngine; +using UnityEngine.UI; +using ZC; + +namespace ZEditor +{ + public class GenProcedureEditor : OdinEditorWindow + { + public string logicFolderPath = $"{Application.dataPath}/DemoGame/GameScript/Hotfix/Procedure/Logic"; + public string templatePath = $"{Application.dataPath}/DemoGame/GameRes/ProcedureLogicTemplate.txt"; + + public string className; + + [MenuItem("Tool/ProcedureTool")] + public static void OpenWin() + { + GetWindow().Show(); + } + + [Button("创建")] + void Gen() + { + if (string.IsNullOrEmpty(className)) + { + Debug.LogError($"{className} is null !!! "); + return; + } + + var tmpName = $"{this.className}Procedure"; + string filePath = $"{logicFolderPath}/{tmpName}.cs"; + string allText; + if (!File.Exists(filePath)) + { + File.Create(filePath).Dispose(); + allText = File.ReadAllText(templatePath); + allText = allText.Replace("#CLASSNAME#", tmpName); + File.WriteAllText(filePath, allText); + } + else + { + Debug.LogError($"重复!已存在{tmpName}.cs文件!"); + return; + } + } + } +} \ No newline at end of file diff --git a/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs.meta b/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs.meta new file mode 100644 index 0000000..69e04fd --- /dev/null +++ b/Assets/DemoGame/GameScript/Editor/GenProcedureEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6fb1eb88d4e040b7bb68dc16235c1e7b +timeCreated: 1732263264 \ No newline at end of file diff --git a/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureAttribute.cs b/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureAttribute.cs index f752a5b..b8d8d8c 100644 --- a/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureAttribute.cs +++ b/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureAttribute.cs @@ -3,7 +3,7 @@ namespace ZC { [AttributeUsage(AttributeTargets.Class)] - class ProcedureAttribute: Attribute + public class ProcedureAttribute: Attribute { public ProcedureType ProcedureType { get; set; } diff --git a/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureBase.cs b/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureBase.cs index 4a169dd..6a926f1 100644 --- a/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureBase.cs +++ b/Assets/DemoGame/GameScript/Hotfix/Procedure/ProcedureBase.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace ZC { - abstract class ProcedureBase : IProcedure + public abstract class ProcedureBase : IProcedure { private ProcedureType _procedureType;