72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using Sirenix.OdinInspector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Cal
|
|
{
|
|
[CreateAssetMenu]
|
|
public class TeamplateTool:Sirenix.OdinInspector.SerializedScriptableObject
|
|
{
|
|
public TextAsset templateTxt;
|
|
public TextAsset templateOpenUITxt;
|
|
public TextAsset templateUIEventTxt;
|
|
public TextAsset templateUIEventTypeTxt;
|
|
|
|
public string className;
|
|
public string uiRootName;
|
|
private string uiName=>uiRootName+"_"+className;
|
|
|
|
[FolderPath(AbsolutePath = false)]
|
|
public string pathRoot;
|
|
|
|
[FolderPath(AbsolutePath = false)]
|
|
public string pathEvent;
|
|
|
|
public void GenerateOpenUIEvent()
|
|
{
|
|
string str = templateOpenUITxt.text;
|
|
str = str.Replace("#className#", className);
|
|
str = str.Replace("#uiName#", uiName);
|
|
ET.Utility.FileOpation.CreateDirectory(Path.Combine(pathRoot, className));
|
|
string path = Path.Combine(pathRoot, className, $"Open{className}Event.cs");
|
|
ET.Utility.FileOpation.WriteString(path,str);
|
|
|
|
str = templateUIEventTypeTxt.text;
|
|
str = str.Replace("#className#", className);
|
|
str = str.Replace("#uiName#", uiName);
|
|
ET.Utility.FileOpation.CreateDirectory(Path.Combine(pathEvent));
|
|
path = Path.Combine(pathEvent, $"EventType.Open{className}.cs");
|
|
ET.Utility.FileOpation.WriteString(path,str);
|
|
|
|
AssetDatabase.Refresh();
|
|
}
|
|
[Button("生成UI")]
|
|
public void GenerateUI()
|
|
{
|
|
string str = templateTxt.text;
|
|
str = str.Replace("#className#", className);
|
|
str = str.Replace("#uiName#", uiName);
|
|
ET.Utility.FileOpation.CreateDirectory(Path.Combine(pathRoot, className));
|
|
string path = Path.Combine(pathRoot, className, $"{className}.cs");
|
|
ET.Utility.FileOpation.WriteString(path,str);
|
|
GenerateUIEvent();
|
|
GenerateOpenUIEvent();
|
|
AssetDatabase.Refresh();
|
|
}
|
|
public void GenerateUIEvent()
|
|
{
|
|
string str = templateUIEventTxt.text;
|
|
str = str.Replace("#className#", className);
|
|
str = str.Replace("#uiName#", uiName);
|
|
ET.Utility.FileOpation.CreateDirectory(Path.Combine(pathRoot, className));
|
|
string path = Path.Combine(pathRoot, className, $"{className}Event.cs");
|
|
ET.Utility.FileOpation.WriteString(path,str);
|
|
AssetDatabase.Refresh();
|
|
|
|
}
|
|
}
|
|
}
|