Reputation: 261
I am totally new to Augmented Reality and Unity 3D. The project that I am working on requires me to load a 3D object onto to the camera only after I select it from a list.
For example, First page will give you a list say Apple, Orange, Mango and when I click on Apple the 3D apple model should appear on the camera.
Can any of you tell me how to load the 3D model from an asset Bundle onto the target at run time ?
Upvotes: 1
Views: 1107
Reputation: 10701
Download your model and instantiate it under the target object. That object contains the TrackingBehaviour component which simply looks of renderer and collider under the target object.
protected virtual void OnTrackingFound()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
// Enable rendering:
foreach (Renderer component in rendererComponents)
{
component.enabled = true;
}
// Enable colliders:
foreach (Collider component in colliderComponents)
{
component.enabled = true;
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
}
So if your object is placed under that object, it will be affected by the track/loss of the marker automatically.
As for downloading the AssetBundle: https://unity3d.com/learn/tutorials/topics/scripting/assetbundles-and-assetbundle-manager
Upvotes: 1