Assetbundle loads in editor but not when built onto android
I am using unity3d 5.5.2f1 and vuforia 6.2 sdk. I have built asset bundles for android and uploaded it to my server. I am using vuforia to detect markers and then attach the asset bundle to the marker. The script works well in the editor. However after building it and running on the android, it doesn't work. I checked whether its problem with vuforia by attaching another game object to the target. That one appears while on editor and on phone. However only gameobject is getting attached after building on to android and not the assetbundle. link text
using System;
using UnityEngine;
using System.Collections;
using Vuforia;
public class Loadmyasset : MonoBehaviour, ITrackableEventHandler
{
public string AssetName;
public int Version;
private GameObject mBundleInstance = null;
private TrackableBehaviour mTrackableBehaviour;
private bool mAttached = false;
public string BundleURL;
void Start()
{
StartCoroutine(DownloadAndCache());
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}
IEnumerator DownloadAndCache ()
{
// Wait for the Caching system to be ready
while (!Caching.ready)
yield return null;
BundleURL = "http://rksunityftpserver.x10host.com/assetbundle/Android/tree.unity3d";
// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
using (WWW www = WWW.LoadFromCacheOrDownload (BundleURL, 1))
{
yield return www;
if (www.error != null)
throw new Exception("WWW download had an error:" + www.error);
AssetBundle bundle = www.assetBundle;
if (AssetName == "")
Instantiate(bundle.mainAsset);
else
Instantiate(bundle.LoadAsset(AssetName));
// Unload the AssetBundles compressed contents to conserve memory
bundle.Unload(false);
} // memory is freed from the web stream (www.Dispose() gets called implicitly)
}
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 (10.0f, 10.0f, 10.0f);
mBundleInstance.transform.localPosition = new Vector3 (0.0f, 0.15f, 0.0f);
mBundleInstance.transform.gameObject.SetActive (true);
mAttached = true;
}
}
}
}
Please help me on this
Answer by Honorsoft · Nov 24, 2017 at 01:38 AM
I am getting a similar problem when building for PC. The asset bundle works perfectly in the Editor, but any *.exe builds just hang and won't load any assets. I am new to asset bundles, but am using the Unity AssetBundle tutorial. Can anyone help?
Your answer
Follow this Question
Related Questions
Android Vuforia dosen't download the asset bundle form a server 0 Answers
URGENT - Loading a scene from asset bundle - Android 0 Answers
AssetBundle.LoadFromFile cause Inflate Error: (file zip crc32 : 00000000) (result: fffffffb) 1 Answer
Android and AssetBundle LoadFromFile 1 Answer
Please Help !!!!!! Baked lightmaps does not work with asset bundle on Ios and Android builds 1 Answer