Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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;