State-Based Model Targets in Unity¶
Import your State-Based Model Targets into Unity and author your AR experience.
Refer to State-Based Model Targets API Overview for a guide using the native C++ API.
Unity Setup¶
Import State-Based Model Targets into Unity as you would with standard Model Targets. Select the database from a ModelTargetBehaviour
to track and report its status and status info like any other Model Target.
Reporting and visualizing active states¶
You can report the currently recognized or manually set state with the ModelTarget.GetActiveStateName()
method. Remember that it is not guaranteed that the currently recognized state is the exact same state the target actually is in.
It is also possible to visualize the currently active state by rendering its geometry with an outline or any other shader. This is best done by selecting Add Target Representation from the inspector of the ModelTargetBehaviour
. This will add a representation for every state, named after the state's name.
The following script demonstrates getting the representations from a Model Target GameObject, applying a custom material to every mesh of the representation, and logging the currently active state in the console.
Add your Model Target GameObject, its Representation Root Node, and a custom Render Material to the script's public fields.
The Render Material used in our example uses the Transparent/VertexLit with Z shader and has a main color with a lower alpha value.
Manually set the active state¶
SetActiveStateName()
is for manually switching the state of a Model Target, and it is necessary to call this function when you use standard (non-trained) State-Based Model Targets with Guide Views to switch them to a specific state. This could, for example, be done from a UI that allows the user to go through the different actions of an assembly procedure.
The GetAvailableStateNames()
returns all available state names of the Model Target.
Learn More¶
Illustration Files and Process Plans for State-Based Model Targets