add:添加流程快速创建工具

master
zxl 2024-11-22 16:43:16 +08:00
parent 80c1178b95
commit cbd3ba86b8
6 changed files with 72 additions and 2 deletions

View File

@ -0,0 +1,10 @@
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace ZC
{
[Procedure(ProcedureType.#CLASSNAME#)]
class #CLASSNAME# : ProcedureBase
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 91e9b42addbc4e5ea673fb5d36a7a685
timeCreated: 1732263928

View File

@ -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<GenProcedureEditor>().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;
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6fb1eb88d4e040b7bb68dc16235c1e7b
timeCreated: 1732263264

View File

@ -3,7 +3,7 @@
namespace ZC
{
[AttributeUsage(AttributeTargets.Class)]
class ProcedureAttribute: Attribute
public class ProcedureAttribute: Attribute
{
public ProcedureType ProcedureType { get; set; }

View File

@ -3,7 +3,7 @@ using UnityEngine;
namespace ZC
{
abstract class ProcedureBase : IProcedure
public abstract class ProcedureBase : IProcedure
{
private ProcedureType _procedureType;