Ejemplo n.º 1
0
        /// <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完成!");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 拷贝当前到其他目录
        /// </summary>
        /// <param name="sourceh"></param>
        public static void CopySqlToOther(string root, RuntimePlatform sourcePlatform)
        {
            RuntimePlatform[] ps = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.IPhonePlayer, RuntimePlatform.Android };

            var target = SqliteLoder.GetLocalDBPath(root, sourcePlatform);
            var bytes  = File.ReadAllBytes(target);

            //拷贝当前到其他目录

            foreach (var p in ps)
            {
                var outpath = SqliteLoder.GetLocalDBPath(root, p);
                if (target == outpath)
                {
                    continue;
                }
                FileHelper.WriteAllBytes(outpath, bytes);
            }
        }
Ejemplo n.º 3
0
        public static void GenJsonToSQLite(string outPath)
        {
            var tablePath = IPath.Combine(Application.dataPath, "Resource/Table");
            var tableDir  = Path.GetDirectoryName(tablePath);
            var jsonFiles = Directory.GetFiles(tableDir, "*.json", SearchOption.AllDirectories);
            var _path     = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            foreach (var f in jsonFiles)
            {
                string content = File.ReadAllText(f);
                Json2Sqlite(f, content);
            }

            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Ejemplo n.º 4
0
        public static void GenJsonToSQLite(List <string> paths)
        {
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            foreach (var f in paths)
            {
                string content = File.ReadAllText(f);

                Json2Sqlite(f, content);
            }

            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Ejemplo n.º 5
0
        public static void Json2SqliteQuick()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            path = Path.GetFullPath(path);
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            string content = File.ReadAllText(path);

            Debug.Log(path);
            Json2Sqlite(path, content);
            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="ouptputPath">自定义路径</param>
        public static void AllExcel2SQLite(string ouptputPath, RuntimePlatform platform, DBType dbType = DBType.Local)
        {
            //触发bd环境周期
            BDFrameworkPipelineHelper.OnBeginBuildSqlite();
            var xlslFiles = ExcelEditorTools.GetAllExcelFiles();

            switch (dbType)
            {
            case DBType.Local:
                SqliteLoder.LoadLocalDBOnEditor(ouptputPath, platform);
                break;

            case DBType.Server:
                SqliteLoder.LoadServerDBOnEditor(ouptputPath, platform);
                break;
            }

            //清空表
            SqliteHelper.DB.Connection.DropTable <ImportExcelLog>();
            {
                foreach (var f in xlslFiles)
                {
                    try
                    {
                        Excel2SQLite(f, dbType);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                        Debug.LogError("导表失败:" + f);
                        EditorUtility.ClearProgressBar();
                    }
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDFrameworkPipelineHelper.OnEndBuildSqlite(ouptputPath);
            GlobalAssetsHelper.GenBasePackageAssetBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
        /// <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)
                {
                    Excel2SQLite(f);
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDFrameEditorBehaviorHelper.OnEndBuildSqlite(ouptputPath);
            AssetHelper.AssetHelper.GenPackageBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
Ejemplo n.º 8
0
        static public void BDEditorInit()
        {
            #region 注册所以管理器,让管理器在编辑器下生效

            //项目所有类
            var types = typeof(BDLauncher).Assembly.GetTypes().ToList();
            //编辑器所有类
            var editorTypes = typeof(BDEditorMenuEnum).Assembly.GetTypes();
            types.AddRange(editorTypes);

            List <IMgr> mgrs = new List <IMgr>();
            foreach (var t in types)
            {
                if (t != null && t.BaseType != null && t.BaseType.FullName != null &&
                    t.BaseType.FullName.Contains(".ManagerBase`2"))
                {
                    var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as IMgr;
                    mgrs.Add(i);
                    continue;
                }
            }

            foreach (var t in types)
            {
                foreach (var mgr in mgrs)
                {
                    mgr.CheckType(t);
                }
            }


            Debug.Log("BDFrameEditor:管理器注册完成");
            #endregion

            DebuggerServerProcessManager.Inst.Start();
            BDEditorHelper.Init();
            BResources.Load("");
            SqliteLoder.Load(Application.streamingAssetsPath);
        }
Ejemplo n.º 9
0
        /// <summary>

        #region 启动热更逻辑

        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="mainProjectTypes">Editor模式下,UPM隔离了DLL需要手动传入</param>
        /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
        public void Launch(Type[] mainProjectTypes, Action <bool> clrBindingAction, string gameId = "default")
        {
            BDebug.Log("【Launch】Persistent:" + Application.persistentDataPath);
            BDebug.Log("【Launch】StreamingAsset:" + Application.streamingAssetsPath);
            //主工程启动
            IGameStart mainStart;

            foreach (var type in mainProjectTypes)
            {
                //TODO 这里有可能先访问到 IGamestart的Adaptor
                if (type.IsClass && type.GetInterface(nameof(IGameStart)) != null)
                {
                    BDebug.Log("【Launch】主工程Start! " + type.FullName);
                    mainStart = Activator.CreateInstance(type) as IGameStart;
                    if (mainStart != null)
                    {
                        //注册
                        mainStart.Start();
                        OnUpdate     += mainStart.Update;
                        OnLateUpdate += mainStart.LateUpdate;
                        break;
                    }
                }
            }


            BDebug.Log("【Launch】框架资源版本验证!");
            //开始资源检测
            BasePackageAssetsHelper.CheckBasePackageVersion(BApplication.RuntimePlatform, () =>
            {
                //1.美术目录
                BResources.Init(GameConfig.ArtRoot);
                //2.sql
                SqliteLoder.Init(GameConfig.SQLRoot);
                //3.脚本,这个启动会开启所有的逻辑
                ScriptLoder.Init(GameConfig.CodeRoot, GameConfig.CodeRunMode, mainProjectTypes, clrBindingAction);
            });
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="ouptputPath">自定义路径</param>
        public static void AllExcel2SQLite(string ouptputPath, RuntimePlatform platform, DBType dbType = DBType.Local)
        {
            //触发bd环境周期
            BDEditorBehaviorHelper.OnBeginBuildSqlite();
            var xlslFiles = GetAllConfigFiles();

            switch (dbType)
            {
            case DBType.Local:
                SqliteLoder.LoadLocalDBOnEditor(ouptputPath, platform);
                break;

            case DBType.Server:
                SqliteLoder.LoadServerDBOnEditor(ouptputPath, platform);
                break;
            }
            {
                foreach (var f in xlslFiles)
                {
                    try
                    {
                        Excel2SQLite(f, dbType);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("导表失败:" + f);
                        EditorUtility.ClearProgressBar();
                    }
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDEditorBehaviorHelper.OnEndBuildSqlite(ouptputPath);
            AssetHelper.AssetHelper.GenPackageBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="scriptPath"></param>
        /// <param name="artPath"></param>
        /// <param name=""></param>
        public void Launch()
        {
            //初始化资源加载
            BResources.Init(IsAssetbundleModel);
            SqliteLoder.Init();


            if (IsAssetbundleModel)
            {
                //开始启动逻辑
                var dd = DataListenerServer.Create("BDFrameLife");
                dd.AddData("OnAssetBundleOever");
                dd.AddListener("OnAssetBundleOever", (o) =>
                {
                    //等待ab完成后,开始脚本逻辑
                    LaunchScrpit();
                });
            }
            else
            {
                LaunchScrpit();
            }
        }
Ejemplo n.º 12
0
        static public void OnForceImpotChangedExcel()
        {
            //判断是否导入设置
            if (BDEditorApplication.BDFrameWorkFrameEditorSetting.BuildSetting.IsForceImportChangedExcelOnWillEnterPlaymode)
            {
                var changedExcelList = ExcelEditorTools.GetChangedExcels();
                if (changedExcelList.Count > 0)
                {
                    BDebug.Log("-----------------强制导入修改的excel文件.begin-----------------", "red");

                    SqliteLoder.LoadLocalDBOnEditor(Application.streamingAssetsPath, BApplication.RuntimePlatform);
                    {
                        //开始导入
                        foreach (var excel in changedExcelList)
                        {
                            var path = AssetDatabase.GUIDToAssetPath(excel);
                            Excel2SQLiteTools.Excel2SQLite(path, DBType.Local);
                        }
                    }
                    SqliteLoder.Close();
                    BDebug.Log("-----------------强制导入修改的excel文件.end-----------------", "red");
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 所有json导入sqlite
        /// </summary>
        public static void ALLJson2SQLite()
        {
            var jsonFiles = Excel2SQLiteTools.GetAllConfigFiles("*.json");

            //连接数据库
            SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
            {
                foreach (var f in jsonFiles)
                {
                    try
                    {
                        string content = File.ReadAllText(f);
                        Json2Sqlite(f, content);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("导表失败:" + f);
                    }
                }
            }
            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
        }
Ejemplo n.º 14
0
 static public void Close()
 {
     SqliteLoder.Close();
 }
Ejemplo n.º 15
0
        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
        public void Launch(string GameId = "")
        {
            //初始化资源加载
            string coderoot = "";
            string sqlroot  = "";
            string artroot  = "";

            //各自的路径
            //art
            if (ArtRoot == AssetLoadPath.Editor)
            {
                if (Application.isEditor)
                {
                    //默认不走AssetBundle
                    artroot = "";
                }
                else
                {
                    //手机默认直接读取Assetbundle
                    artroot = Application.persistentDataPath;
                }
            }
            else if (ArtRoot == AssetLoadPath.Persistent)
            {
                artroot = Application.persistentDataPath;
            }

            else if (ArtRoot == AssetLoadPath.StreamingAsset)
            {
                artroot = Application.streamingAssetsPath;
            }

            //sql
            if (SQLRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                sqlroot = Application.streamingAssetsPath;
            }

            else if (SQLRoot == AssetLoadPath.Persistent)
            {
                sqlroot = Application.persistentDataPath;
            }
            else if (SQLRoot == AssetLoadPath.StreamingAsset)
            {
                sqlroot = Application.streamingAssetsPath;
            }

            //code
            if (CodeRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                coderoot = "";
            }

            else if (CodeRoot == AssetLoadPath.Persistent)
            {
                coderoot = Application.persistentDataPath;
            }
            else if (CodeRoot == AssetLoadPath.StreamingAsset)
            {
                coderoot = Application.streamingAssetsPath;
            }

            //多游戏更新逻辑
            if (Application.isEditor == false)
            {
                if (GameId != "")
                {
                    artroot  = artroot + "/" + GameId;
                    coderoot = coderoot + "/" + GameId;
                    sqlroot  = sqlroot + "/" + GameId;
                }
            }

            //sql
            SqliteLoder.Load(sqlroot);
            //art
            BResources.Load(artroot);
            //code
            LoadScrpit(coderoot);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
        public void Launch(string GameId = "")
        {
            //初始化资源加载
            string coderoot = "";
            string sqlroot  = "";
            string artroot  = "";

            //各自的路径
            //art
            if (ArtRoot == AssetLoadPath.Editor)
            {
                if (Application.isEditor)
                {
                    //默认不走AssetBundle
                    artroot = "";
                }
                else
                {
                    //手机默认直接读取Assetbundle
                    artroot = Application.persistentDataPath;
                }
            }
            else if (ArtRoot == AssetLoadPath.Persistent)
            {
                artroot = Application.persistentDataPath;
            }

            else if (ArtRoot == AssetLoadPath.StreamingAsset)
            {
                artroot = Application.streamingAssetsPath;
            }
            //sql
            if (SQLRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                sqlroot = Application.streamingAssetsPath;
            }

            else if (SQLRoot == AssetLoadPath.Persistent)
            {
                sqlroot = Application.persistentDataPath;
            }
            else if (SQLRoot == AssetLoadPath.StreamingAsset)
            {
                sqlroot = Application.streamingAssetsPath;
            }

            //code
            if (CodeRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                coderoot = "";
            }

            else if (CodeRoot == AssetLoadPath.Persistent)
            {
                coderoot = Application.persistentDataPath;
            }
            else if (CodeRoot == AssetLoadPath.StreamingAsset)
            {
                coderoot = Application.streamingAssetsPath;
            }

            //多游戏更新逻辑
            if (Application.isEditor == false)
            {
                if (GameId != "")
                {
                    artroot  = artroot + "/" + GameId;
                    coderoot = coderoot + "/" + GameId;
                    sqlroot  = sqlroot + "/" + GameId;
                }
            }


            //开始初始化
            BResources.Load(artroot);
            SqliteLoder.Load(sqlroot);
            //非内部加载
            if (artroot != "")
            {
                //开始启动逻辑
                var dd = DataListenerServer.Create("BDFrameLife");
                dd.AddData("OnAssetBundleOever");
                dd.AddListener("OnAssetBundleOever", (o) =>
                {
                    //等待ab完成后,开始脚本逻辑
                    LoadScrpit(coderoot);
                });
            }
            else
            {
                LoadScrpit(coderoot);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
        public void Launch(string GameId = "")
        {
            //初始化资源加载
            string coderoot = "";
            string sqlroot  = "";
            string artroot  = "";

            //各自的路径
            //art
            if (Config.ArtRoot == AssetLoadPath.Editor)
            {
                if (Application.isEditor)
                {
                    //默认不走AssetBundle
                    artroot = "";
                }
                else
                {
                    //手机默认直接读取Assetbundle
                    artroot = Application.persistentDataPath;
                }
            }
            else if (Config.ArtRoot == AssetLoadPath.Persistent)
            {
                artroot = Application.persistentDataPath;
            }

            else if (Config.ArtRoot == AssetLoadPath.StreamingAsset)
            {
                if (string.IsNullOrEmpty(Config.CustomArtRoot) == false)
                {
                    artroot = Config.CustomArtRoot;
                }
                else
                {
                    artroot = Application.streamingAssetsPath;
                }
            }

            //sql
            if (Config.SQLRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                sqlroot = Application.streamingAssetsPath;
            }

            else if (Config.SQLRoot == AssetLoadPath.Persistent)
            {
                sqlroot = Application.persistentDataPath;
            }
            else if (Config.SQLRoot == AssetLoadPath.StreamingAsset)
            {
                sqlroot = Application.streamingAssetsPath;
            }

            //code
            if (Config.CodeRoot == AssetLoadPath.Editor)
            {
                //sql 默认读streaming
                coderoot = "";
            }
            else if (Config.CodeRoot == AssetLoadPath.Persistent)
            {
                coderoot = Application.persistentDataPath;
            }
            else if (Config.CodeRoot == AssetLoadPath.StreamingAsset)
            {
                coderoot = Application.streamingAssetsPath;
            }

            //多游戏更新逻辑
            if (Application.isEditor == false)
            {
                if (GameId != "")
                {
                    artroot  = artroot + "/" + GameId;
                    coderoot = coderoot + "/" + GameId;
                    sqlroot  = sqlroot + "/" + GameId;
                }
            }

            //异步
            BResources.Load(artroot, () =>
            {
                //sql
                SqliteLoder.Load(sqlroot);
                //异步 这里如果代码很早的时候就开始走表格逻辑,有可能报错,
                //但是大部分游戏应该不会,三层回调太丑,暂时用这个

                ScriptLoder.Load(coderoot, Config.CodeRunMode);
            });


            if (OnBDFrameLaunch != null)
            {
                OnBDFrameLaunch();
            }
        }
Ejemplo n.º 18
0
 static public void OpenSqlite()
 {
     SqliteLoder.Load(Application.streamingAssetsPath);
 }