Log in or register to post comments

New Asset Bundle works on unity player but not on android phone

January 31, 2016 - 8:39pm #1

Hello everybody,

I am very new to Vuforia and unity. I am trying to implement asset bundles in my AR project. Everything seems to work fine in unity player on android platform. But the same app when I try to run on my android device nothing happens. I have loaded the asset bundle on a Filezilla FTP server. I have also built the AB for android platform. The 3D model is also compatible and is of a few Kbs only. when I tried to store the AB on my phone then the app worked fine but doesn't work when downloaded through FTP server. Below is my code. Any kind of help would be very useful.

Thank you.

using UnityEngine;
using System.Collections;
using System;
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() 
 {
  StartCoroutine(DownloadAndCache());
  mTrackableBehaviour = GetComponent<TrackableBehaviour>();
  if (mTrackableBehaviour) 
  {
   mTrackableBehaviour.RegisterTrackableEventHandler(this);
  }
 }
 
 
 // Update is called once per frame
 IEnumerator DownloadAndCache() 
 {
  //  while(!Caching.ready)
  //   yield return null;
  
  
  string bundleURL = ftp://ftp@xxx.xx.xxx.xx/AssetBundles/Android/beanbag;
  
  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);
    mBundleInstance.transform.gameObject.SetActive(true);
    mAttached = true;
    
    
   }
  }
 }
}

 

New Asset Bundle works on unity player but not on android phone

June 9, 2017 - 4:57am #2

Hi ! 



I was just wondering if you succeeded to make it work. I'm stuck since last week on a project where I can't display the 3D Model on my ImageTarget with an android device, but only when I put the asset bundle on a server. So if you have any advice for that as you had the same issue, it would be really nice of you ! 



Thank you really much !

Log in or register to post comments