| | |
| | | } |
| | | } |
| | | |
| | | public static void CreateConfigClass(FileInfo fileInfo) |
| | | public static void CreateConfigClass(FileInfo fileInfo, bool isIL = false) |
| | | { |
| | | var lines = File.ReadAllLines(fileInfo.FullName); |
| | | if (lines.Length > 2) |
| | |
| | | |
| | | filedContent = string.Join("\r\n\t", fieldFulls.ToArray()); |
| | | readContent = string.Join("\r\n\r\n\t\t\t", readFulls.ToArray()); |
| | | CreatNewConfigClass(fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'))); |
| | | CreatNewConfigClass(fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.')), isIL); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | return StringUtility.Contact("int.TryParse(tables", "[", index, "]", ",", "out ", field, ")", "; "); |
| | | } |
| | | else if (type.Contains("long")) |
| | | { |
| | | return StringUtility.Contact("long.TryParse(tables", "[", index, "]", ",", "out ", field, ")", "; "); |
| | | } |
| | | else if (type.Contains("float")) |
| | | { |
| | | return StringUtility.Contact("float.TryParse(tables", "[", index, "]", ",", "out ", field, ")", "; "); |
| | |
| | | } |
| | | } |
| | | |
| | | static string configClassPath = "Assets" + "/" + "Scripts/Core/GameEngine/Model/Config"; |
| | | static string configClassPath = "Assets/Scripts/Core/GameEngine/Model/Config"; |
| | | static string configILClassPath = "LogicProject/Src/Config"; |
| | | static string templatePath = "Assets/Editor/ScriptTemplate/ConfigDataTemplate.txt"; |
| | | |
| | | public static void CreatNewConfigClass(string _name) |
| | | public static void CreatNewConfigClass(string _name, bool isIL) |
| | | { |
| | | var newConfigPath = configClassPath + string.Format("/{0}Config.cs", _name); |
| | | string newConfigPath; |
| | | if (isIL) |
| | | { |
| | | newConfigPath = configILClassPath + string.Format("/IL{0}Config.cs", _name); |
| | | } |
| | | else |
| | | { |
| | | newConfigPath = configClassPath + string.Format("/{0}Config.cs", _name); |
| | | } |
| | | AssetDatabase.DeleteAsset(newConfigPath); |
| | | UnityEngine.Object o = CreateScriptAssetFromTemplate(newConfigPath, templatePath); |
| | | UnityEngine.Object o = CreateScriptAssetFromTemplate(newConfigPath, templatePath, isIL); |
| | | ProjectWindowUtil.ShowCreatedAsset(o); |
| | | } |
| | | |
| | | internal static UnityEngine.Object CreateScriptAssetFromTemplate(string pathName, string resourceFile) |
| | | internal static UnityEngine.Object CreateScriptAssetFromTemplate(string pathName, string resourceFile, bool isIL) |
| | | { |
| | | string fullPath = Path.GetFullPath(pathName); |
| | | |
| | |
| | | text = Regex.Replace(text, "#DateTime#", System.DateTime.Now.ToLongDateString()); |
| | | text = Regex.Replace(text, "#Field#", CreateConfigClassFile.filedContent); |
| | | text = Regex.Replace(text, "#Read#", CreateConfigClassFile.readContent); |
| | | text = Regex.Replace(text, "#FileName#", fileNameWithoutExtension.Substring(0, fileNameWithoutExtension.Length - 6)); |
| | | if (isIL) |
| | | { |
| | | text = Regex.Replace(text, "#FileName#", fileNameWithoutExtension.Substring(2, fileNameWithoutExtension.Length - 8)); |
| | | } |
| | | else |
| | | { |
| | | text = Regex.Replace(text, "#FileName#", fileNameWithoutExtension.Substring(0, fileNameWithoutExtension.Length - 6)); |
| | | } |
| | | |
| | | bool encoderShouldEmitUTF8Identifier = true; |
| | | bool throwOnInvalidBytes = false; |