AR Annotations in Unity — Adding Labels to AR Objects

Paul Killman
Antaeus AR
Published in
4 min readMar 1, 2024

In this article, I will describe how to add an annotation to an AR Object. An annotation is an object or text that floats somewhere near an AR Object.

In previous articles, I have described how to add various AR Interactable components to an AR Object. Adding AR Annotations is no different. I have a prefab that I’ve created to use as my AR Object.

I opened it up and then added the AR Annotation Interactable component.

Because this is a prefab and not part of the scene, I am unable to add values to the Interaction Manager or XR Origin. I am, however, able to add the Red Cube to the Colliders.

I next added an Annotation by expanding the Annotations field and clicking the + button.

The Unity XR Interaction Toolkit document describes what each of the Annotation fields are for. For my annotation, I’m going to add some text that says, “Cube”.

I added a Text Mesh Pro Text object as a child of the Red Cube.

Since I haven’t already added Text Mesh Pro to this project, I need to import Text Mesh Pro essentials.

I now have some text attached to my cube.

I renamed the object as Annotation Text and changed the text to, “Cube”. I also played with the settings some to get it to the size that I wanted.

Now, back to the AR Annotation Interactable. I drug the Annotation Text object to the Annotation Visualization field. I didn’t know what values to use for the other fields, so I just used the default values listed in the document.

XR Interaction Toolkit

These values tell the AR Annotation Interactable when to display the annotation. If the annotation is within a certain angle of the Field of View and within the min/max Annotation Range, then the annotation will be displayed.

Because the AR Annotation Interactable component is deciding when to display the annotation, I turned the annotation text off. It will be turned on when the parameters described above are met.

Here’s the final settings I used on this component.

Time to try it out. I built the project and installed it on my mobile device. On my first attempt, I could not get the annotation to appear. I changed the Max FOV Center Offset Angle to 1 and tried again.

Now the annotation appears and disappears as I move the mobile device.

In the first picture below, I have the cube more or less centered in the screen.

In this picture, I move the mobile device so that it’s pointing away from the cube. The annotation disappears.

--

--