void ExtractUpk()
 {
     ResetProgress(Status.Extract);
     StartThread(delegate {
         if (File.Exists(_upkPath))
         {
             FingerPrint.StartWriting(_bundleFolder);
             if (UPKExtra.ExtraUPK(_upkPath, _bundleFolder, _progress, true, delegate(string path, byte[] bytes) {
                 FingerPrint.AddItem(path, MiscUtils.GetMd5HashFromBytes(bytes), _bundleFolder);
             }))
             {
                 FingerPrint.Flush();
                 ChangeStatus(Status.Done);
                 File.Delete(_upkPath);
             }
             else
             {
                 Fail();
             }
         }
         else
         {
             ChangeStatus(Status.Request);
         }
     });
 }
Beispiel #2
0
    private void CheckFingerPrintWithServer(string json)
    {
        string   url      = "Assetbundle/CheckBundle";
        JsonData tempData = new JsonData();

                #if UNITY_ANDROID
        tempData["local_files"]    = json;
        tempData["no_compression"] = "1";
                #else
        tempData["local_files"] = Convert.ToBase64String(GZipUtil.Zip(json));
                #endif

        byte[] Data = System.Text.Encoding.UTF8.GetBytes(tempData.ToJson());
        StaticMonoBehaviour.Instance.StartCoroutine(HttpRequest.Instance.WebRequest(HttpRequest.HttpReqType.POST, url, Data, (string Json) => {
            JsonData tempJson = JsonMapper.ToObject(Json);
            JsonData data     = tempJson["data"];
                        #if UNITY_ANDROID
            string filesUpdate = data ["file_to_update"].ToString();
            string filesDelete = data ["file_to_delete"].ToString();
                        #else
            string filesUpdate = GZipUtil.UnZipToString(Convert.FromBase64String(data["file_to_update"].ToString()));
            string filesDelete = GZipUtil.UnZipToString(Convert.FromBase64String(data["file_to_delete"].ToString()));
            LogManager.Log("file_to_update: " + filesUpdate);
            LogManager.Log("file_to_delete: " + filesDelete);
                        #endif
            FingerPrint.StartWriting(m_AssetBundlePath);
            if (!string.IsNullOrEmpty(filesDelete))
            {
                JsonData jdFilesDelete = JsonMapper.ToObject(filesDelete);
                for (int i = 0; i < jdFilesDelete.Count; ++i)
                {
                    var filePath = m_AssetBundlePath + jdFilesDelete[i].ToString();
                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                    FingerPrint.DeleteItem(filePath, m_AssetBundlePath);
                }
            }
            FingerPrint.Flush();
            //有需要更新的文件
            if (!string.IsNullOrEmpty(filesUpdate))
            {
                JsonData jdFilesUpdate = JsonMapper.ToObject(filesUpdate);
                string staticServer    = data["static_server"].ToString();
                string platformPath    = data["platform_path"].ToString();
                List <string> paths    = GetPathFromJson(jdFilesUpdate, "");
                if (paths.Count > 0)
                {
                    DownloadFiles(paths, staticServer, platformPath);
                }
                else
                {
                    Ready();
                }
            }
        }, NetworkFail));
    }
Beispiel #3
0
    private void DownloadFiles(List <string> paths, string staticServer, string platformPath)
    {
        m_FailedBundles.Clear();
        m_WaitForDownloadBundles.Clear();
        FingerPrint.StartWriting(m_AssetBundlePath);

        for (int i = 0; i < paths.Count; ++i)
        {
            var url        = staticServer + "/" + platformPath + "/" + paths[i];
            var bundleInfo = new BundleInfo()
            {
                _url = url, _path = paths[i]
            };
            m_WaitForDownloadBundles.Add(bundleInfo);
        }

        if (m_WaitForDownloadBundles.Count == 0)
        {
            Ready();
        }
        else
        {
            m_DownloadIndex = 0;
            m_Status        = Status.DownloadingSmallBundles;
            LogManager.Log("Start download bundle!");
            if (!Directory.Exists(m_AssetBundlePath))
            {
                Directory.CreateDirectory(m_AssetBundlePath);
            }
            string[] files = Directory.GetFiles(m_AssetBundlePath, "*.*", SearchOption.AllDirectories);
            m_DownloadedNum = files.Length;
            m_TotalFileNum  = m_WaitForDownloadBundles.Count + files.Length;

            AssetBundleSaveData.Instance.RefreshDownloadStatus((int)AssetBundleSaveData.BigZipDownloadStatus.Downloading);
            StartDownloadAtIndex();
        }
    }