Exemple #1
0
 private void _UsingAssetBundlesFromLocal()
 {
     this._AddLogOutput("Downloading from Local StreamingAssets.");
     AssetManager.UseBundles   = true;
     this._baseUrl             = BundleSceneIOS.GetBasedURLForLocalBundles();
     this._isDownloading       = true;
     this._isCompressedBundles = true;
     base.StartCoroutine(this.DownloadAssetBundles());
 }
Exemple #2
0
    public static String GetFullURLForLocalBundles(Boolean isCompressedBundles, String bundleName)
    {
        String text = String.Concat(new String[]
        {
            BundleSceneIOS.GetBasedURLForLocalBundles(),
            AssetManagerUtil.GetPlatformPrefix(Application.platform),
            AssetManagerUtil.GetCompressionPrefix(isCompressedBundles),
            bundleName,
            AssetManagerUtil.GetBundleExtension()
        });

        global::Debug.Log("GetFullURLForLocalBundles = " + text);
        return(text);
    }
Exemple #3
0
    public IEnumerator DownloadAssetBundle(AssetManager.AssetBundleRef abRef, Int32 curItem, Int32 numItem)
    {
        while (!Caching.ready)
        {
            yield return(null);
        }
        this._AddLogOutput("Downloading : " + abRef.url);
        String fullUrl = String.Concat(new String[]
        {
            this._baseUrl,
            AssetManagerUtil.GetPlatformPrefix(Application.platform),
            AssetManagerUtil.GetCompressionPrefix(this._isCompressedBundles),
            abRef.url,
            AssetManagerUtil.GetBundleExtension()
        });

        this._AddLogOutput("    At : " + fullUrl);
        String  prefix = AssetManagerUtil.GetPlatformPrefix(Application.platform);
        Boolean isCompressedBundles = this._isCompressedBundles;
        Boolean specialCaseOccured  = fullUrl.Contains(prefix + "0data2.bin") || fullUrl.Contains(prefix + "0data3.bin") || fullUrl.Contains(prefix + "0data4.bin");

        if (specialCaseOccured)
        {
            isCompressedBundles = true;
            String baseUrl = String.Empty;
            baseUrl = BundleSceneIOS.GetBasedURLForLocalBundles();
            fullUrl = String.Concat(new String[]
            {
                baseUrl,
                AssetManagerUtil.GetPlatformPrefix(Application.platform),
                AssetManagerUtil.GetCompressionPrefix(isCompressedBundles),
                abRef.url,
                AssetManagerUtil.GetBundleExtension()
            });
        }
        if (!isCompressedBundles && fullUrl.IndexOf("http://") == -1)
        {
            this._AddLogOutput("Loading Uncompressed Bundle.");
            AssetBundle ab = AssetBundle.CreateFromFile(fullUrl);
            abRef.assetBundle = ab;
            yield break;
        }
        Boolean isVersionCached = false;

        if (specialCaseOccured && Caching.IsVersionCached(fullUrl, BundleScene.BundleVersionInt))
        {
            this.LoadingUI.SetSceneActive(false);
            isVersionCached = true;
        }
        using (WWW www = WWW.LoadFromCacheOrDownload(fullUrl, BundleScene.BundleVersionInt))
        {
            this._AddLogOutput("Loading Compressed Bundle.");
            while (!www.isDone)
            {
                if (!isVersionCached)
                {
                    this.LoadingUI.SetSceneActive(true);
                    this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressOBB, ExpansionVerifier.ErrorCode.None);
                }
                Single total         = ((Single)this.currentProgressIndex + www.progress) * 100f;
                Single totalProgress = total / 4f;
                this.LoadingUI.SetProgress(Mathf.FloorToInt(totalProgress), true);
                global::Debug.Log("totalProgress + " + totalProgress);
                yield return(new WaitForSeconds(0.01f));
            }
            this.currentProgressIndex++;
            if (www.error != null)
            {
                this._AddLogOutput("Error : " + www.error);
                throw new Exception("WWW download:" + www.error);
            }
            abRef.assetBundle = www.assetBundle;
        }
        yield break;
    }