Exemplo n.º 1
0
        public void CheckAndDownload(DownloadTable table)
        {
            CheckUpdateTable checkUpdateTable = new CheckUpdateTable()
            {
                Complete = (string moduleName, int downloadCount, string sizeStr) =>
                {
                    //2.下载模块
                    Download(table);
                },
                Error = (string moduleName) =>
                {
                    Debug.LogError("下载失败");
                }
            };

            //1.检查更新
            CheckUpdate(checkUpdateTable, false);
        }
Exemplo n.º 2
0
        public void CheckUpdate(CheckUpdateTable table, bool isGetSize)
        {
            //编辑器模式模拟检查完成
            if (GameConfig.gameModel == GameModel.Editor)
            {
                if (table != null && table.Complete != null)
                {
                    table.Complete(Name, 0, string.Empty);
                    return;
                }
            }
            CheckUpdateBehaviour cub = new GameObject(Name + "_CheckUpdateBehaviour").AddComponent <CheckUpdateBehaviour>();

            cub.CheckUpdate(Name, isGetSize, (Md5File md5File, long size) =>
            {
                _size          = size;
                _md5File       = md5File;
                _downloadQueue = md5File.DownloadQueue;
                _sizeStr       = Util.HumanReadableFilesize(Convert.ToDouble(_size));
                if (table == null)
                {
                    return;
                }
                if (_downloadQueue == null)
                {
                    Debug.LogError(string.Format("{0}:检查更新失败!", Name));
                    if (table.Error != null)
                    {
                        table.Error(Name);
                    }
                    return;
                }
                Debug.Log(Name + " 需要下载 " + _sizeStr);
                if (table.Complete != null)
                {
                    table.Complete(Name, _downloadQueue.Count, _sizeStr);
                }
                Destroy(cub.gameObject);
                cub = null;
            });
        }