2024-10-24 23:44:04 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Ether
|
|
|
|
|
{
|
|
|
|
|
public static class TempTools
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成类
|
|
|
|
|
/// </summary>
|
2024-10-28 03:42:42 +08:00
|
|
|
|
public static void GenerateClassFile(string className, string baseClassName, string content, string generatePath)
|
2024-10-24 23:44:04 +08:00
|
|
|
|
{
|
|
|
|
|
string tempClassStr = FileTools.ReadFile(PathTools.TempClassPath);
|
|
|
|
|
tempClassStr = tempClassStr.Replace("$ClassName$", className);
|
|
|
|
|
tempClassStr = tempClassStr.Replace("$BaseClassName$", baseClassName);
|
|
|
|
|
tempClassStr = tempClassStr.Replace("$Content$", content);
|
|
|
|
|
|
|
|
|
|
FileTools.WriteFile(generatePath, tempClassStr);
|
|
|
|
|
}
|
2024-10-28 03:42:42 +08:00
|
|
|
|
|
|
|
|
|
public static void GenerateEnumFile(string enumName, Dictionary<string, string> enumDic, string generatePath)
|
|
|
|
|
{
|
|
|
|
|
string tempEnumStr = FileTools.ReadFile(PathTools.TempEnumPath);
|
|
|
|
|
tempEnumStr = tempEnumStr.Replace("$EnumName$", enumName);
|
|
|
|
|
|
|
|
|
|
string tempStr = "";
|
|
|
|
|
foreach (var enumPair in enumDic)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(enumPair.Value))
|
|
|
|
|
{
|
|
|
|
|
tempStr += $"\t\t[InspectorName(\"{enumPair.Value}\")]\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(enumPair.Key))
|
|
|
|
|
{
|
|
|
|
|
tempStr += $"\t\t{enumPair.Key},\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tempEnumStr = tempEnumStr.Replace("$Content$", tempStr);
|
|
|
|
|
|
|
|
|
|
FileTools.WriteFile(generatePath, tempEnumStr);
|
|
|
|
|
}
|
2024-10-24 23:44:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|