Unity AR Interface

Sean Duggan
2 min readFeb 14, 2024

--

Now that we have two different items that we can place in our world, it would be nice to be able to use both of them, instead of just compiling for one. We’ve touched a bit on UI before. As it turns out, it’s just as applicable when it comes to AR applications. We’ll start by adding a Canvas to the scene. As usual, it pops up huge compared to the scene, since its size is measured in pixels, while we’re usually working on the scale of meters, but tapping F to focus on the Canvas element, and moving to 2D, helps put the matter into perspective, so to speak.

Speaking of perspective, it’s worth noting that if we change our Game window to Simulator, we can choose the resolution to match a particular phone.

We’ll add a button for switching for now.

And anchor it to the bottom of the screen.

And because I want the size of the button to be approximately the same for all screens, I change the Canvas Scaler to set the UI Scale Mode to Scale With Screen Size.

Hmm… I’m actually going to do one button for each object, and put them with a parent with the Horizontal Layout Group.

From there, it’s just a matter of setting the events on the buttons to change the Prefab for the placed object, and it all just kind of works.

--

--