Пример #1
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("Persistent:" + Application.persistentDataPath);
            BDebug.Log("StreamingAsset:" + Application.streamingAssetsPath);
            //主工程启动
            IGameStart mainStart;

            foreach (var type in mainProjectTypes)
            {
                if (type.GetInterface(nameof(IGameStart)) != null)
                {
                    mainStart = Activator.CreateInstance(type) as IGameStart;
                    //注册
                    mainStart.Start();
                    OnUpdate     += mainStart.Update;
                    OnLateUpdate += mainStart.LateUpdate;
                    break;
                }
            }

            //开始资源检测
            AssetHelper.AssetHelper.CheckAssetPackageVersion(Application.platform, () =>
            {
                //1.美术目录
                BResources.Load(GameConfig.ArtRoot, GameConfig.CustomArtRoot);
                //2.sql
                SqliteLoder.Load(GameConfig.SQLRoot);
                //3.脚本,这个启动会开启所有的逻辑
                ScriptLoder.Load(GameConfig.CodeRoot, GameConfig.CodeRunMode, mainProjectTypes, clrBindingAction);
            });
        }
Пример #2
0
 /// <summary>
 /// 初始化
 /// 修改版本,让这个启动逻辑由使用者自行处理
 /// </summary>
 /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
 public void Launch(string GameId = "")
 {
     BDebug.Log("Persistent:" + Application.persistentDataPath);
     BDebug.Log("StreamingAsset:" + Application.streamingAssetsPath);
     //开始资源检测
     AssetHelper.AssetHelper.CheckAssetPackageVersion(Application.platform, () =>
     {
         //1.美术目录
         BResources.Load(GameConfig.ArtRoot, GameConfig.CustomArtRoot);
         //2.sql
         SqliteLoder.Load(GameConfig.SQLRoot);
         //3.脚本,这个启动会开启所有的逻辑
         ScriptLoder.Load(GameConfig.CodeRoot, GameConfig.CodeRunMode);
     });
 }
Пример #3
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();
            }
        }