| | |
| | | public static string readContent = string.Empty;
|
| | |
|
| | |
|
| | | [UnityEditor.MenuItem("Assets/生成配置解析类型")]
|
| | | public static void GenerateConfigClass()
|
| | | [UnityEditor.MenuItem("Assets/生成配置解析类型1")]
|
| | | public static void GenerateConfigClass1()
|
| | | {
|
| | |
|
| | | if (Selection.objects != null)
|
| | |
| | | if (type.Contains("int[][]"))
|
| | | {
|
| | | return StringUtility.Contact("public readonly int[][] ", field.Trim(), ";");
|
| | | }
|
| | | else if (type.Contains("Dictionary<int, int>"))
|
| | | {
|
| | | return StringUtility.Contact("public readonly Dictionary<int, int> ", field.Trim(), ";");
|
| | | }
|
| | | else if (type.Contains("Dictionary<int, int[]>"))
|
| | | {
|
| | | return StringUtility.Contact("public readonly Dictionary<int, int[]> ", field.Trim(), ";");
|
| | | }
|
| | | else if (type.Contains("float[][]"))
|
| | | {
|
| | | return StringUtility.Contact("public readonly float[][] ", field.Trim(), ";");
|
| | | }
|
| | | else if (type.Contains("int[]"))
|
| | | {
|
| | |
| | |
|
| | | public static string GetRead(string type, string field, int index)
|
| | | {
|
| | | |
| | | field = field.Replace(" ", "");
|
| | | if (type.Contains("int[][]"))
|
| | | {
|
| | | return StringUtility.Contact(field, " = JsonMapper.ToObject<int[][]>(tables", "[", index, "]", ")", "; ");
|
| | | return StringUtility.Contact(field, " = JsonMapper.ToObject<int[][]>(tables", "[", index, "].Replace(\"(\", \"[\").Replace(\")\", \"]\")); ");
|
| | | }
|
| | | else if (type.Contains("Dictionary<int, int>"))
|
| | | {
|
| | | return StringUtility.Contact(field, " = ConfigParse.ParseIntDict(tables", "[", index, "]); ");
|
| | | }
|
| | | else if (type.Contains("Dictionary<int, int[]>"))
|
| | | {
|
| | | return StringUtility.Contact(field, " = ConfigParse.ParseIntArrayDict(tables", "[", index, "]); ");
|
| | | }
|
| | | else if (type.Contains("float[][]"))
|
| | | {
|
| | | return StringUtility.Contact(field, " = JsonMapper.ToObject<float[][]>(tables", "[", index, "].Replace(\"(\", \"[\").Replace(\")\", \"]\")); ");
|
| | | }
|
| | | else if (type.Contains("int[]"))
|
| | | {
|
| | |
| | | }
|
| | | else if (type.Contains("float[]"))
|
| | | {
|
| | | var line1 = StringUtility.Contact("string[] ", field, "StringArray", " = ", "tables", "[", index, "]", ".Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);", "\n");
|
| | | var line2 = StringUtility.Contact(retract3, field, " = ", "new float", "[", field, "StringArray.Length", "]", ";", "\n");
|
| | | var line3 = StringUtility.Contact(retract3, "for (int i=0;i<", field, "StringArray", ".Length", ";", "i++", ")", "\n");
|
| | | var line4 = StringUtility.Contact(retract3, "{\n");
|
| | | var line5 = StringUtility.Contact(retract4, " float.TryParse(", field, "StringArray", "[i]", ",", "out ", field, "[i]", ")", ";", "\n");
|
| | | var line6 = StringUtility.Contact(retract3, "}");
|
| | | var line0 = StringUtility.Contact("if (tables", "[", index, "].Contains(\"[\"))\n");
|
| | | var line0_1 = StringUtility.Contact(retract3, "{\n");
|
| | | var line0_2 = StringUtility.Contact(retract4, field, " = JsonMapper.ToObject<float[]>(tables", "[", index, "]);\n");
|
| | | var line0_3 = StringUtility.Contact(retract3, "}\n");
|
| | | var line0_4 = StringUtility.Contact(retract3, "else\n");
|
| | | var line0_5 = StringUtility.Contact(retract3, "{\n");
|
| | | var line1 = StringUtility.Contact(retract4, "string[] ", field, "StringArray", " = ", "tables", "[", index, "]", ".Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);", "\n");
|
| | | var line2 = StringUtility.Contact(retract4, field, " = ", "new float", "[", field, "StringArray.Length", "]", ";", "\n");
|
| | | var line3 = StringUtility.Contact(retract4, "for (int i=0;i<", field, "StringArray", ".Length", ";", "i++", ")", "\n");
|
| | | var line4 = StringUtility.Contact(retract4, "{\n");
|
| | | var line5 = StringUtility.Contact(retract5, " float.TryParse(", field, "StringArray", "[i]", ",", "out ", field, "[i]", ")", ";", "\n");
|
| | | var line6 = StringUtility.Contact(retract4, "}\n");
|
| | | var line0_6 = StringUtility.Contact(retract3, "}");
|
| | |
|
| | | return StringUtility.Contact(line1, line2, line3, line4, line5, line6);
|
| | | return StringUtility.Contact(line0, line0_1, line0_2, line0_3, line0_4, line0_5, line1, line2, line3, line4, line5, line6, line0_6);
|
| | | }
|
| | | else if (type.Contains("string[]"))
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | static string configClassPath = "Assets/Scripts/Core/GameEngine/Model/Config";
|
| | | static string configILClassPath = "LogicProject/Src/Config";
|
| | | static string configILClassPath = "Assets/Scripts/LogicProject/Config";
|
| | | static string templatePath = "Assets/Editor/ScriptTemplate/ConfigDataTemplate.txt";
|
| | |
|
| | | public static void CreatNewConfigClass(string _name, bool isIL)
|
| | | {
|
| | | string newConfigPath;
|
| | | newConfigPath = configILClassPath + string.Format("/IL{0}Config.cs", _name);
|
| | | if (File.Exists(newConfigPath))
|
| | | {
|
| | | //默认兼容旧的ILRuntime表,如果要生成新的先删除旧的表代码
|
| | | isIL = true;
|
| | | }
|
| | | if (isIL)
|
| | | {
|
| | | newConfigPath = configILClassPath + string.Format("/IL{0}Config.cs", _name);
|