示例#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());
 }
示例#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);
    }
示例#3
0
    public IEnumerator DownloadAssetBundles()
    {
        Screen.sleepTimeout = -1;
        Int32 curItem = 0;
        Int32 numItem = AssetManager.DictAssetBundleRefs.Count;

        if (!BundleSceneIOS.Are3CompressedBundlesCached())
        {
            global::Debug.Log("Need to check free space");
            if (Storage.GetFreeSpace() < 382335908UL)
            {
                this.LoadingUI.SetSceneActive(true);
                this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressFailure, ExpansionVerifier.ErrorCode.NotEnoughStorage);
                yield break;
            }
            AssetManager.ClearCache();
            Single curTime = Time.realtimeSinceStartup;
            Single percent = 0f;
            while (Time.realtimeSinceStartup - curTime < 5f)
            {
                percent = (Time.realtimeSinceStartup - curTime) / 5f;
                this.LoadingUI.SetSceneActive(true);
                this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressOBB, ExpansionVerifier.ErrorCode.None);
                Single total         = ((Single)this.currentProgressIndex + percent) * 100f;
                Single totalProgress = total / 4f;
                this.LoadingUI.SetProgress(Mathf.FloorToInt(totalProgress), true);
                yield return(new WaitForSeconds(0.3f));
            }
            this.currentProgressIndex++;
        }
        foreach (KeyValuePair <String, AssetManager.AssetBundleRef> entry in AssetManager.DictAssetBundleRefs)
        {
            AssetManager.AssetBundleRef abRef = entry.Value;
            if (abRef.assetBundle != (UnityEngine.Object)null)
            {
                break;
            }
            yield return(base.StartCoroutine(this.DownloadAssetBundle(abRef, curItem, numItem)));

            curItem++;
        }
        this._SetStatusText("Load Completed");
        Screen.sleepTimeout = -2;
        this._OnDownloadFinished();
        yield return(null);

        yield break;
    }
示例#4
0
    private void Awake()
    {
        global::Debug.Log("10 BundleSceneSelector.Awake");
        Boolean flag = false;

        String[] files = Directory.GetFiles("./", "*steam_appid.txt", SearchOption.AllDirectories);
        String[] array = files;
        for (Int32 i = 0; i < (Int32)array.Length; i++)
        {
            String   fileName = array[i];
            FileInfo fileInfo = new FileInfo(fileName);
            if (fileInfo.IsReadOnly)
            {
                fileInfo.IsReadOnly = false;
            }
            fileInfo.Delete();
        }
        if (SteamSdkWrapper.SteamAPIRestartAppIfNecessary())
        {
            Application.Quit();
            return;
        }
        if (Application.platform == RuntimePlatform.IPhonePlayer || flag)
        {
            if (BundleSceneIOS.Are3CompressedBundlesCached())
            {
                global::Debug.Log("All 3 compressed bundles are cachaed. Go to SplashScreen");
                Application.LoadLevel("SplashScreen");
            }
            else
            {
                global::Debug.Log("Some compressed bundles are NOT cached. Go to Bundle-iOS");
                Application.LoadLevel("Bundle-iOS");
            }
        }
        else
        {
            Application.LoadLevel("SplashScreen");
        }
    }
示例#5
0
    public static Boolean Are3CompressedBundlesCached()
    {
        String  fullURLForLocalBundles = BundleSceneIOS.GetFullURLForLocalBundles(true, AssetManagerUtil.GetModuleBundleName(AssetManagerUtil.ModuleBundle.BattleMaps));
        Boolean flag = Caching.IsVersionCached(fullURLForLocalBundles, BundleScene.BundleVersionInt);

        fullURLForLocalBundles = BundleSceneIOS.GetFullURLForLocalBundles(true, AssetManagerUtil.GetModuleBundleName(AssetManagerUtil.ModuleBundle.WorldMaps));
        Boolean flag2 = Caching.IsVersionCached(fullURLForLocalBundles, BundleScene.BundleVersionInt);

        fullURLForLocalBundles = BundleSceneIOS.GetFullURLForLocalBundles(true, AssetManagerUtil.GetModuleBundleName(AssetManagerUtil.ModuleBundle.Models));
        Boolean flag3 = Caching.IsVersionCached(fullURLForLocalBundles, BundleScene.BundleVersionInt);

        global::Debug.Log(String.Concat(new Object[]
        {
            "Are3CompressedBundlesCached: isBundle2Cached = ",
            flag,
            ", isBundle3Cached = ",
            flag2,
            ", isBundle4Cached = ",
            flag3
        }));
        return(flag && flag2 && flag3);
    }
示例#6
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;
    }