public static void ExecuteGenSqlite()
        {
            var outpath_win =
                IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform));

            Excel2SQLiteTools.GenSQLite(outpath_win);

            var outpath_android = Application.streamingAssetsPath + "/" +
                                  BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/Local.db";
            var outpath_ios = Application.streamingAssetsPath + "/" +
                              BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/Local.db";
            var source = outpath_win + "/Local.db";

            var bytes = File.ReadAllBytes(source);

            if (source != outpath_android)
            {
                FileHelper.WriteAllBytes(outpath_android, bytes);
            }
            if (source != outpath_ios)
            {
                FileHelper.WriteAllBytes(outpath_ios, bytes);
            }

            AssetDatabase.Refresh();
        }
Пример #2
0
        /// <summary>
        /// 生成代码
        /// </summary>
        public static void GenCode(string outputPath)
        {
            var xlslFiles = Excel2SQLiteTools.GetAllConfigFiles();

            //
            if (xlslFiles.Count == 0)
            {
                EditorUtility.DisplayDialog("提示", "未发现xlsx文件,请注意不是xls", "确定");
                return;
            }

            //同名文件判断
            var fnlist = xlslFiles.Select((s) => Path.GetFileName(s).ToLower()).ToList();

            foreach (var fn in fnlist)
            {
                var rets = fnlist.FindAll((f) => f == fn);
                if (rets.Count > 1)
                {
                    EditorUtility.DisplayDialog("提示", "Sqlite表名 字段名不区分大小写,请处理重名exel! ->" + fn, "OK");

                    return;
                }
            }

            //导出excel
            foreach (var f in xlslFiles)
            {
                GenClassByExcel(outputPath, f, "Local");
                GenClassByExcel(outputPath, f, "Server");
            }

            EditorUtility.DisplayDialog("提示", "生成完成!", "确定");
            AssetDatabase.Refresh();
        }
Пример #3
0
        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("自动导表完成!");
        }
Пример #4
0
        public void OnGUI()
        {
            GUILayout.BeginVertical();
            GUILayout.Label("3.表格打包", EditorGUIHelper.TitleStyle);
            GUILayout.Space(5);
            if (GUILayout.Button("表格导出成Sqlite", GUILayout.Width(300), GUILayout.Height(30)))
            {
                //3.打包表格
                Excel2SQLiteTools.AllExcel2SQLite(Application.streamingAssetsPath, Application.platform);
                Excel2SQLiteTools.CopySqlToOther(Application.streamingAssetsPath, Application.platform);
            }

            GUILayout.EndVertical();
        }
Пример #5
0
        public void OnGUI()
        {
            GUILayout.BeginVertical();
            GUILayout.Label("3.表格打包", EditorGUIHelper.TitleStyle);
            GUILayout.Space(5);
            if (GUILayout.Button("表格导出成Sqlite", GUILayout.Width(300), GUILayout.Height(30)))
            {
                var outPath = Application.persistentDataPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android);
                //3.打包表格
                Excel2SQLiteTools.GenSQLite(outPath);
            }

            GUILayout.EndVertical();
        }
Пример #6
0
        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 ExecuteJsonToSqlite()
 {
     Excel2SQLiteTools.GenJsonToSQLite(IPath.Combine(Application.streamingAssetsPath,
                                                     BDUtils.GetPlatformPath(Application.platform)));
     Debug.Log("表格导出完毕");
 }