using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Ether { public static class TempTools { /// /// 生成类 /// public static void GenerateClassFile(string className, string baseClassName, string content, string generatePath) { 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); } public static void GenerateEnumFile(string enumName, Dictionary 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); } } }