Annotations: Labeling the World | AR Unity Developer

Derek Anderson
2 min readApr 15, 2024

--

With the capability of moving, rotating, and re-scaling objects, this AR project is coming along nicely. Having shapes is nice, but there’s more that can be done to provide more information and detail about a selected object in the AR app. This is where AR Annotations come into play.

The AR Annotation Interactable places labels over objects and other features in a scene to highlight something important. These annotations can disappear when the object is out of visibility or if the object is too far away. Objects can have more than one annotation.

Like the other AR Interactables, the AR Annotation Interactable is added to the placement prefab. However, there isn’t much this interactable can do currently. The range where these annotations can be changed, as well as the Offset Angle, but an Annotation Visualization is needed to actually see the annotations on the placement prefab. The numbers below for the Offset Angle and the Annotation Ranges are the values listed in the Unity Documentation of the AR Annotation Interactable. By default, the numbers for the Annotations are set at zero.

Create a child TextMeshPro GameObject to the cube in the placement prefab. If this is the first time using TextMeshPro in the project, a popup will appear to import the TMP Essentials. Click on that to get TextMeshPro set up. Once that is done, modify the text for the cube, including placement, font size, and alignment. Rename it as AnnotationVis and drag it into the corresponding field in the AR Annotation Interactable component of the placement prefab. Make sure the visualization is disabled, as it should only appear when the shape is selected.

Once the Annotation Visualization is set, it’s time to test it in action. In my tests, I had to change a few settings because the annotation was only visible when the phone camera was set at a certain distance and angle from the placement prefab. This involved changing the Offset Angle settings and switching the Distance Calculation Mode from Collider Position to Collider Volume. After some changes, I was able to get the annotations to appear without much trouble.

--

--