Exemplo n.º 1
0
 /// <summary>
 /// 解压AssetBundle.zip文件到PresistentData
 /// </summary>
 private void DecompressInstallFile()
 {
     //检查磁盘空间是否满足大小 todo
     if ((long)Math.Ceiling(installZipDecompressSize * 1.1f) > MobileSystemInfo.GetFreeDiskSpace())
     {
         //磁盘空间不足
     }
     else
     {
         ZipUtility.DeCompressionFile(
             PathUtility.GetCombinePath(AppConst.Path.InstallDataPath,
                                        AppConst.AssetBundleConfig.AssetBundlePackageFile), AppConst.Path.PresistentDataPath,
             installZipDecompressPassword);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 加载server上的filelist callback
        /// </summary>
        /// <param name="isOk"></param>
        /// <param name="datas"></param>
        /// <param name="errorMessage"></param>
        private void LoadServerFileListCallback(bool isOk, byte[] datas, string errorMessage)
        {
            newFileInfoTable.Clear();
            if (isOk && datas != null && datas.Length > 0)
            {
                using (ByteBuffer buffer = new ByteBuffer(datas))
                {
                    fileCount = ValueParse.ReadValue(buffer, ValueParse.IntParse);
                    for (int i = 0; i < fileCount; i++)
                    {
                        UpdateFileInfo updateFileInfo = new UpdateFileInfo
                        {
                            AssetBundleName = ValueParse.ReadValue(buffer, ValueParse.StringParse),
                            Length          = ValueParse.ReadValue(buffer, ValueParse.IntParse),
                            Md5Code         = ValueParse.ReadValue(buffer, ValueParse.IntParse),
                            ZipLength       = ValueParse.ReadValue(buffer, ValueParse.IntParse),
                            ZipMd5Code      = ValueParse.ReadValue(buffer, ValueParse.IntParse)
                        };
                        newFileInfoTable.Add(updateFileInfo.AssetBundleName, updateFileInfo);
                    }
                }
                DeleteUselessFiles();
                GetDownloadFileList();
                if (!isUpdateDone)
                {
                    BeginDownFile();
                    return;

                    //检查磁盘空间是否满足大小 todo
                    if ((long)Math.Ceiling(totalDownloadSize * 1.1f) > MobileSystemInfo.GetFreeDiskSpace())
                    {
                        //磁盘空间不足
                    }
                    else
                    {
                        if (MobileSystemInfo.NetAvailable)
                        {
                            //运营商网络
                            if (MobileSystemInfo.IsCarrier)
                            {
                                updatePanel.ShowMessageBox(UpdatePanel.enMessageBoxType.CancelOk,
                                                           UpdateStringConfig.UpdateStatusBeginUpdate,
                                                           UpdateStringConfig.UpdateStringHasErrorNotWifi,
                                                           BeginDownFile, () =>
                                {
                                    if (Application.isPlaying)
                                    {
                                        Application.Quit();
                                    }
                                }, UpdateStringConfig.UpdateStatusWifiTips, FormatDownloadSize(totalDownloadSize));
                            }
                            // wi-fi 网络
                            else if (MobileSystemInfo.IsWifi)
                            {
                                //弹出提示框询问是否下载
                                updatePanel.ShowMessageBox(UpdatePanel.enMessageBoxType.CancelOk,
                                                           UpdateStringConfig.UpdateStatusBeginUpdate,
                                                           UpdateStringConfig.UpdateStateStartUpdateInfo,
                                                           BeginDownFile, () =>
                                {
                                    if (Application.isPlaying)
                                    {
                                        Application.Quit();
                                    }
                                }, UpdateStringConfig.UpdateStatusWifiTips, FormatDownloadSize(totalDownloadSize));
                            }
                        }
                    }
                }
            }
            else
            {
                //获取服务器的FileList失败
                isUpdateDone = true;
                updateError("获取服务器最新版本的文件列表信息失败");
            }
        }