/// <summary> /// 创建数据基类脚本(方法重载) /// </summary> /// <param name="cofigLoadType">配置表类型</param> /// <param name="textAsset">text格式数据</param> private static void CreateDatabaseScript(EnumCofigLoadType cofigLoadType, TextAsset textAsset) { DATA_ID++; string template = string.Empty; string configPath = string.Empty; switch (cofigLoadType) { case EnumCofigLoadType.Streaming: template = GetTemplate(ConfigDefine.TEMPLATE_DATABASE_STREAMING_PATH); configPath = ConfigDefine.CSV_STREAMING_ENCRYPT_PATH + textAsset.name + ".txt"; break; case EnumCofigLoadType.Resources: template = GetTemplate(ConfigDefine.TEMPLATE_DATABASE_RESOURECES_PATH); configPath = ConfigDefine.CSV_RESOUCES_ENCRYPT_PATH + textAsset.name + ".txt"; break; } template = template.Replace("$DataClassName", textAsset.name + "Data"); template = template.Replace("$DataAttributes", GetClassParameters(textAsset)); template = template.Replace("$CsvSerialize", GetCsvSerialize(textAsset)); template = template.Replace("$DataTypeName", textAsset.name + "Database"); template = template.Replace("$DataID", DATA_ID.ToString()); template = template.Replace("$DataPath", "\"" + textAsset.name + "\""); GenerateScript(textAsset.name + "Database", template); CsvEncrypt(configPath, textAsset.text); }
/// <summary> /// 创建数据基类脚本 /// </summary> /// <param name="cofigLoadType">配置表加载类型</param> /// <param name="csvPaths">CSV数据路径</param> private static void CreateDatabaseScript(EnumCofigLoadType cofigLoadType, string[] csvPaths) { string assetPath = ""; TextAsset textAsset = null; for (int cnt = 0; cnt < csvPaths.Length; cnt++) { assetPath = "Assets" + csvPaths[cnt].Replace(Application.dataPath, "").Replace('\\', '/'); textAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(assetPath, typeof(TextAsset)); REGISTER_LIST += string.Format("RegisterDataType(new {0}Database());\n", textAsset.name); if (cnt != csvPaths.Length - 1) { REGISTER_LIST += "\t\t\t"; } CONVERT_LIST += string.Format("CsvToJsonConverter.Convert<{0}Data>(\"{0}\"); \n", textAsset.name); if (cnt != csvPaths.Length - 1) { CONVERT_LIST += "\t\t\t"; } CreateDatabaseScript(cofigLoadType, textAsset); } }