Beispiel #1
0
 private IEnumerator loadForLocalABPath(string keyPath)
 {
     using (DecompressWhileRef counter = new DecompressWhileRef())
     {
         string abFilePath = ABPathHelper.AssetsWWWStreamURL + keyPath;
         if (abFilePath.IndexOf(ABPathHelper.MP4Suffix) < 0)
         {
             WWW wwwWithPakFile = new WWW(abFilePath);
             if (wwwWithPakFile != null)
             {
                 while (!wwwWithPakFile.isDone)
                 {
                     yield return(null);
                 }
                 abFilePath = ABPathHelper.AssetsLocalABURL + keyPath;
                 ABHelper.CacheFile(abFilePath, wwwWithPakFile.bytes);
                 wwwWithPakFile.Dispose();
             }
         }
     }
 }
Beispiel #2
0
    /// <summary>
    /// 进行跟包资源的解压缩
    /// </summary>
    /// <returns></returns>
    public IEnumerator doDecompressAB()
    {
        //读取并存储跟包的MD5s
        yield return(StartCoroutine(loadWithPakMD5s()));

        //读取并存储跟包的Manifest
        string strManifestPath = ABPathHelper.AssetsWWWStreamURL + ABPathHelper.platformFolder;
        WWW    wwwManifest     = new WWW(strManifestPath);

        if (wwwManifest != null)
        {
            while (!wwwManifest.isDone && string.IsNullOrEmpty(wwwManifest.error))
            {
                yield return(null);
            }

            strManifestPath = ABPathHelper.AssetsLocalABURL + ABPathHelper.platformFolder;
            File.WriteAllBytes(strManifestPath, wwwManifest.bytes);

            wwwManifest.Dispose();
        }

        int curProCompressStep = -1;
        int curWithPakIndex    = 0;
        int decompressCount    = DecompressCount;

        if (decompressCount <= 0)
        {
            decompressCount = 3;
        }
        int    clipWithPakCount   = mWithPakMD5s.Count / decompressCount;
        string showDecompressInfo = DecompressInfo;

        for (int i = 0; i < mWithPakMD5s.Count;)
        {
            if (DecompressWhileRef.GetCurRefs() < MAX_DECOMPRESS_HANDLE)
            {
                StartCoroutine(loadForLocalABPath(mWithPakMD5s[i]));
                curWithPakIndex++;
                int proCompressStep  = curWithPakIndex / clipWithPakCount;
                int proCompressIndex = curWithPakIndex % clipWithPakCount;

                //if (Updating != null)
                //{
                //    if (curProCompressStep != proCompressStep)
                //    {
                //        curProCompressStep = proCompressStep;
                //        showDecompressInfo = LoadingUIManager.DecompressInfo + " [" + (proCompressStep + 1) + "/" + decompressCount + "] ";
                //        LoadingUIManager.Instance.ResetUI();
                //    }
                //    Updating(showDecompressInfo, proCompressIndex / (float)clipWithPakCount);
                //}

                i++;
            }
            else
            {
                yield return(null);
            }
        }

        while (DecompressWhileRef.GetCurRefs() > 0)
        {
            yield return(null);
        }

        //全部解压缩完成啦啦啦
        string strDecompressSuccess = ABPathHelper.AssetsLocalABURL + ABPathHelper.DecompressSuccess;

        using (FileStream fs = new FileStream(strDecompressSuccess, FileMode.OpenOrCreate))
        {
            using (StreamWriter sw = new StreamWriter(fs))
            {
                sw.Write(AppVerConfig.curAppVer);
            }
        }
    }