Highlighting an Object
This feature requires the Immerse SDK Enterprise Edition
This is different to the free Immerse SDK. Contact [email protected] if you require access.
Understand the difference between the Free and Enterprise SDK
Highlighting an object can be done in a multitude of ways. The quickest of which is to add a Highlight component, which can be enabled/disabled to highlight the object it is attached to.
Highlighting via Code
To take advantage of the full flexibility of the Highlight package, you will need to highlight via code.
Simple Highlighting
The most simple way to highlight an object is by passing in a GameObject. The code example below demonstrates how to do this.
using ImmerseSDK.Highlight;
...
var highlightHandle = HighlightService.CreateHighlight(gameObject);
The method to create a highlight will return a HighlightHandle
. This object is used when you wish to remove the highlight.
using ImmerseSDK.Highlight;
...
HighlightService.RemoveHighlight(highlightHandle);
If you only wish to temporarily hide the highlight, an Enabled
parameter exists within the HighlightHandle
class that will disable it. However, when you are done with it, it is strongly advised to remove it properly to all Unity to free up memory.
Highlight Config
For more control over the behaviour of the highlight, a HighlightConfig
is required. This object allows you to change settings for a specific highlight such as the material and mesh used and if the highlight should follow the original object being highlighted or not.
The below example demonstrates how to create a highlight that will use 'target' as reference for it's mesh and for it's position/rotation as well as using the custom Material 'material' to draw the highlight.
using ImmerseSDK.Highlight;
...
var config = new HighlightConfig
{
MeshSource = target,
FollowTransform = target,
Material = material
};
var highlightHandle = HighlightService.CreateHighlight(config);
The full list of options available in the HighlightConfig
class are listed below
Description | |
---|---|
Offsets | Position, rotation and scale offsets to use when drawing the mesh. If a Follow Transform is supplied, the offsets are applied from this transform. Otherwise the offsets are applied from the Mesh Source transform or applied directly to a supplied Mesh. |
Mesh | Mesh to draw This takes priority over the MeshSource property |
MeshSource | Transform used to generate the mesh at runtime. Ignored if the Mesh property is supplied |
FollowTransform | Transform that the drawn mesh will follow. If not supplied, the mesh will not follow anything |
Material | Material to draw the mesh with If not supplied, will use the default material from Highlight Settings |
MaterialPropertyBlock | MaterialPropertyBlock for editing material properties If not supplied, will create a new one |
Layer | Layer to draw the mesh If not supplied, will use the default layer from Highlight Settings |
Updated about 1 year ago