Exemple #1
0
        /// <summary>
        /// 初始化
        /// 修改版本,让这个启动逻辑由使用者自行处理
        /// </summary>
        /// <param name="GameId">单游戏更新启动不需要id,多游戏更新需要id号</param>
        public void Launch(string GameId = "")
        {
            //初始化资源加载
            string coderoot  = "";
            string sqlroot   = "";
            string assetroot = "";

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

            else if (Config.ArtRoot == AssetLoadPath.StreamingAsset)
            {
                if (string.IsNullOrEmpty(Config.CustomArtRoot) == false)
                {
                    assetroot = Config.CustomArtRoot;
                }
                else
                {
                    assetroot = 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 != "")
                {
                    assetroot = assetroot + "/" + GameId;
                    coderoot  = coderoot + "/" + GameId;
                    sqlroot   = sqlroot + "/" + GameId;
                }
            }

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