- Home /
Question by
karthees · Oct 06, 2014 at 05:23 AM ·
gameobjectassetbundlevuforia
Display 3D from url
I'm doing vuforia + unity app. I have 3D model in server then i'm getting the url and display into 3D. But some of them suggested to go with Assetbundle. But i have different url randomly user upload their url to my server. So, is there any way to display 3D from url without using AssetBundle or how can i use use AssetBundle for different url?
public string url = "";
mTargetMetadata = targetSearchResult.MetaData;
JSONObject json = JSONObject.Parse(mTargetMetadata);
string type=json.GetString("type");
url=json.GetString("overlay3d");
Debug.Log("url value is " + url );
// stop the target finder (i.e. stop scanning the cloud)
mCloudRecoBehaviour.CloudRecoEnabled = false;
mShowGUIButton = true;
StartCoroutine(GetAssetBundle());
GameObject newImageTarget = Instantiate(ImageTargetTemplate.gameObject) as GameObject;
GameObject augmentation = null;
if( augmentation != null )
augmentation.transform.parent = newImageTarget.transform;
// enable the new result with the same ImageTargetBehaviour:
// ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);
//StartCoroutine(GetAssetBundle());
Debug.Log("Metadata value is " + url );
StartCoroutine(GetAssetBundle());
// Build augmentation based on target
if (ImageTargetTemplate) {
// enable the new result with the same ImageTargetBehaviour:
ImageTracker tracker = TrackerManager.Instance.GetTracker<ImageTracker>();
ImageTargetBehaviour imageTargetBehaviour =
(ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(
targetSearchResult, ImageTargetTemplate.gameObject);
}
IEnumerator GetAssetBundle ()
{
www = new WWW(url);
yield return www;
Debug.Log("The last BundleURL " + url );
AssetBundleRequest request = www.assetBundle.LoadAsync("CloudRecognition", typeof(GameObject));
yield return request;
Instantiate(request.asset, new Vector3(3f, 0f, 0f), Quaternion.identity);
Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);
Instantiate(request.asset, new Vector3(-3f, 0f, 0f), Quaternion.identity);
www.assetBundle.Unload(true);
//Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);
//Put the stream model under the image target
GameObject ImageTargetUsed = GameObject.Find("3DObject");
GameObject ModelIpadClone = GameObject.Find("CloudRecognition(Clone)");
ModelIpadClone.transform.parent = ImageTargetUsed.transform;
}
Comment