示例#1
0
        /// <summary>
        /// 对比可读写文件夹下资源版本和包内资源版本
        /// 加载asb可以从streaming路径加载,不需要将资源拷贝到可读写文件夹
        /// 当包体资源有更新时,删除老的已下载资源包
        /// </summary>
        private void _checkLocalRes()
        {
            if (GameConfig.UseAsb)
            {
                string sUrl = _confUrlStream();
                string wUrl = _confUrlWrite();

                WWWTO streamWWW = WWWTO.ReadFileStr(sUrl, (rst, msg) =>
                {
                    if (rst)
                    {
                        mStreamConf = new ResConf(msg);
                        EventManager.NotifyMain(STR_EVENT_PKG_VERSION, mStreamConf.version);
                    }
                    else
                    {
                        // 该包没有在游戏包体内
                        mStreamConf = new ResConf("");
                    }
                    WWWTO writableWWW = WWWTO.ReadFileStr(wUrl, _onWriteableConf, null);
                    writableWWW.Start();
                }, null);
                streamWWW.Start();
            }
            else
            {
                _callbackLocal(true, "");
            }
        }
示例#2
0
        public void ReadCotainPkgs(Action <bool> callback)
        {
            mCotainCall = callback;
            string url = Tools.GetFileUrl(GameConfig.STR_ASB_MANIFIST + "/version/" + ConfFile);
            WWWTO  www = WWWTO.ReadFileStr(url, _onReadConf, null);

            www.Start();
        }
示例#3
0
        /// <summary>
        /// 对比服务器配置文件,记录新的文件
        /// </summary>
        /// <param name="url">服务器地址 URL.</param>
        /// <param name="callback">Callback.</param>
        private void _compareNewFiles(string url, Action <long, string> callback)
        {
            if (null != callback)
            {
                if (GameConfig.UseAsb)
                {
                    string sUrl = _confUrl(url);
                    string pUrl = _confUrlWrite();

                    WWWTO streamWWW = WWWTO.ReadFileStr(sUrl, (rst, msg) =>
                    {
                        if (rst)
                        {
                            mServConf = new ResConf(msg);

                            WWWTO writableWWW = WWWTO.ReadFileStr(pUrl, (_rst, _msg) =>
                            {
                                if (_rst)
                                {
                                    //之前已经拷贝过资源
                                    mCurConf = new ResConf(_msg);
                                }
                                else
                                {
                                    mCurConf = new ResConf("");
                                }
                                mTotalSize = 0;
                                if (mServConf.CompareVer(mCurConf) > 0)
                                {
                                    mNewFiles = mServConf.GetUpdateFiles(mCurConf);
                                    foreach (var f in mNewFiles)
                                    {
                                        mTotalSize += f.size;
                                    }
                                    callback(mTotalSize, mServConf.version);
                                }
                                else
                                {
                                    LogFile.Log("没有检测到新版本资源,跳过更新步骤");
                                    callback(mTotalSize, "没有检测到新版本资源,跳过更新步骤");
                                }
                            }, null);
                            writableWWW.Start();
                        }
                        else
                        {
                            LogFile.Warn("资源配置文件" + sUrl + "丢失");
                            callback(-1, STR_CONFIG_MISSING);
                        }
                    }, null);
                    streamWWW.Start();
                }
                else
                {
                    callback(0, "不使用Assetbundle不用拷贝/下载资源");
                }
            }
        }