By harunkatirci
on Thu, 10/10/2013 - 10:33
Hi,
I'm new on Vuforia CR . I want to load 3d model dynamically according to targetSearchResult.MetaData value.
I'll do this on OnNewSearchResult but how to implement it?
I try this code but cannot load 3d model.
Thanks.
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) { // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(), // or to create a new ImageTargetBehaviour for each new result // Vuforia will return a new object with the right script automatically if you use // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName) //Check if the metadata isn't null if(targetSearchResult.MetaData == null) { return; } //GUILayout.Label(targetSearchResult.MetaData.ToString()); // enable the new result with the same ImageTargetBehaviour: ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate); if (imageTargetBehaviour != null) { if(targetSearchResult.MetaData.ToString() == "testmetadata") { Transform myModel = GameObject.Instantiate(Resources.Load("MURCIELAGO640")) as Transform; myModel.parent = imageTargetBehaviour.gameObject.transform; myModel.localPosition = new Vector3(0f, 0.002499813f, 0f); myModel.localRotation = Quaternion.identity; myModel.localScale = new Vector3(15f,15f,15f); myModel.gameObject.SetActive(true); } // stop the target finder mCloudRecoBehaviour.CloudRecoEnabled = false; // Calls the TargetCreated Method of the SceneManager object to start loading // the BookData from the JSON //mContentManager.TargetCreated(targetSearchResult.MetaData); } }
How can i load 3d model dynamically from resources
This is more a general question about Unity rather than specific to Vuforia, so we cannot really help you.
How can i load 3d model dynamically from resources
Thanks I have done it
Harun
How can i load 3d model dynamically from resources
Good to hear :)
N