static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { var excelList = new List <string>(); foreach (var asset in importedAssets) { if (asset.EndsWith("xlsx") && asset.Contains("Table")) { excelList.Add(asset); } } SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); if (excelList.Count > 0) { float counter = 1f; foreach (var excel in excelList) { Excel2SQLiteTools.Excel2SQLite(excel); EditorUtility.DisplayProgressBar("自动导表", excel, counter / excelList.Count); counter++; } EditorUtility.ClearProgressBar(); } SqliteLoder.Close(); Debug.Log("自动导表完成!"); }
static public void Insert() { //TODO //暂时热更内不支持创建插入操作 //该条测试可能会对后面有影响 var h1 = new APITestHero() { Id = 1 }; var h2 = new APITestHero() { Id = 2 }; var h3 = new APITestHero() { Id = 3 }; SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); SqliteHelper.DB.CreateDB <APITestHero>(); SqliteHelper.DB.InsertTable(new List <APITestHero>() { h1, h2, h3 }); }
/// <summary> /// 生成sqlite /// 默认导出到当前平台目录下 /// </summary> /// <param name="ouptputPath">自定义路径</param> public static void ALLExcel2SQLite(string ouptputPath, RuntimePlatform platform) { //触发bd环境周期 BDFrameEditorBehaviorHelper.OnBeginBuildSqlite(); var xlslFiles = GetAllConfigFiles(); SqliteLoder.LoadOnEditor(ouptputPath, platform); { foreach (var f in xlslFiles) { try { Excel2SQLite(f); } catch (Exception e) { Debug.LogError("导表失败:" + f); } } } SqliteLoder.Close(); // EditorUtility.ClearProgressBar(); //触发bd环境周期 BDFrameEditorBehaviorHelper.OnEndBuildSqlite(ouptputPath); AssetHelper.AssetHelper.GenPackageBuildInfo(ouptputPath, platform); Debug.Log("导出Sqlite完成!"); }
/// <summary> /// 导入自定义内容到 excel /// 默认为Application.streamingAssetsPath /// </summary> /// <param name="path"></param> public static void GenxslxOrJsonToSQlite(IDictionary <string, string> path) { SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); { foreach (var f in path) { JsonContent2Sqlite(f.Key, f.Value); } } SqliteLoder.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void MenuItem_Excel2Sqlite() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); path = Path.GetFullPath(path); SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); { Excel2SQLite(path); } SqliteLoder.Close(); EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("提示", Path.GetFileName(path) + "\n恭喜你又成功导入一次表格吶~\n呐!呐!呐!呐! ", "OK"); AssetDatabase.Refresh(); }
/// <summary> /// 导入 json 到excel /// 默认为Application.streamingAssetsPath /// </summary> /// <param name="paths"></param> public static void GenJsonToSQLite(List <string> paths) { SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); { foreach (var f in paths) { string content = File.ReadAllText(f); JsonContent2Sqlite(f, content); } } SqliteLoder.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void GenJson2SQLite() { var jsonFiles = Excel2SQLiteTools.GetAllConfigFiles("*.json"); //连接数据库 SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); { foreach (var f in jsonFiles) { string content = File.ReadAllText(f); JsonContent2Sqlite(f, content); } } SqliteLoder.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); }
public static void Json2SqliteQuick() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); path = Path.GetFullPath(path); SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform); { string content = File.ReadAllText(path); Debug.Log(path); JsonContent2Sqlite(path, content); } SqliteLoder.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
/// <summary> /// 生成sqlite /// 默认导出到当前平台目录下 /// </summary> /// <param name="root">自定义路径</param> public static void GenExcel2SQLite(string root, RuntimePlatform platform) { var xlslFiles = GetAllConfigFiles(); // SqliteLoder.LoadOnEditor(root, platform); { foreach (var f in xlslFiles) { var excel = new ExcelUtility(f); var json = excel.GetJson(); JsonContent2Sqlite(f, json); } } SqliteLoder.Close(); // EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); }