Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Asset Bundle download progress bar

Discussion in 'Asset Bundles' started by jorge_nasciment, Feb 8, 2019.

  1. jorge_nasciment


    Apr 3, 2017
    I'm having a hard time developing an app with asset bundle and vuforia: the app is able to download the asset bundle normally when it recognizes the marker, and sets the model to this marker. But the client does not know whether the asset bundle is being downloaded or not, especially in larger files, which require a little more time to download. I wonder if anyone of you can help me put up an indication for as long as the app is downloading the asset bundle.

    Below is my code, adapted from the site of the vuforia:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Vuforia;

    public class AssetBundleAugmenter : MonoBehaviour, ITrackableEventHandler {
    public string AssetName;
    public int Version;
    private GameObject mBundleInstance = null;
    private TrackableBehaviour mTrackableBehaviour;
    private bool mAttached = false;
    void Start() {
    mTrackableBehaviour = GetComponent<TrackableBehaviour>();
    if (mTrackableBehaviour) {
    // Update is called once per frame
    IEnumerator DownloadAndCache() {
    while (!Caching.ready)
    yield return null;
    // example URL of file on PC filesystem (Windows)
    // string bundleURL = "file:///D:/Unity/AssetBundles/MyAssetBundle.unity3d";
    // example URL of file on Android device SD-card
    string bundleURL = "";

    using (WWW www = WWW .LoadFromCacheOrDownload(bundleURL, Version)) {
    yield return www;
    if (www .error != null)
    throw new UnityException("WWW Download had an error: " + www .error);
    AssetBundle bundle = www .assetBundle;
    if (AssetName == "") {
    mBundleInstance = Instantiate (bundle.mainAsset) as GameObject;
    else {
    mBundleInstance = Instantiate(bundle.LoadAsset(AssetName)) as GameObject;
    public void OnTrackableStateChanged(
    TrackableBehaviour.Status previousStatus,
    TrackableBehaviour.Status newStatus) {
    if (newStatus == TrackableBehaviour.Status.DETECTED ||
    newStatus == TrackableBehaviour.Status.TRACKED ||
    newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) {
    if (!mAttached && mBundleInstance) {
    // if bundle has been loaded, let's attach it to this trackable
    mBundleInstance.transform.parent = this.transform;
    mBundleInstance.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
    mBundleInstance.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
    mAttached = true;
    aryan_abbhi likes this.
  2. aryan_abbhi


    Nov 25, 2015
    same problem here cant able to find solution...