Hello,
I have been able to load models at runtime with Asset Bundles in Unity Pro. However, currently my models load right at runtime instead of after image tracking. After image tracking the correct model will lock to the trackable image and rotate normally but do not dissappear after the trackable image is lost. My question is how to only load the model after image tracking? I am loading the asset bundle models into an empty object that is a child of my ImageTarget. On this empty object I attached the following script, if I use a regular object as a child of my imagetarget it does not show up early only the dynamically pulled objects.
Thank you for any help!
using System;
using UnityEngine;
using System.Collections;
public class CachingLoadExample : MonoBehaviour {
public string BundleURL;
public string AssetName;
public int version;
void Start() {
StartCoroutine (DownloadAndCache());
}
IEnumerator DownloadAndCache (){
// Wait for the Caching system to be ready
while (!Caching.ready)
yield return null;
// 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, version)){
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.Load(AssetName));
// Unload the AssetBundles compressed contents to conserve memory
bundle.Unload(false);
// Frees the memory from the web stream
www.Dispose();
}
}
}
Hello YamanakaYue
I have some problem with you. do you found to solve this problem?? if you solve the problem can you post your code.
Thanks. i hope you can hlep me