Designing a Button | Unity Tutorial

In virtual reality (VR) games, one of the few interactions a player can make is press a button by looking at it. In this tutorial, we will design a button in Unity. If you are a beginner and want to learn how to build virtual reality games, check out our Unity3D course!

VR has limited interactions with keys. Other devices like computers or Xbox, which have a lot of keys that players can press to interact with the game. Create a cube in the Hierarchy. We will have the cube work like a button. Give Cube the position 0 -1 -5. Change its X Scale value to 2.

Create a material in the Assets folder. Make sure that you do not create the material in the Google SDK folders. Name the material “ButtonMaterial”. Drag ButtonMaterial to Cube in the Scene. Change the color of ButtonMaterial to green with RGB values such as 0 184 100.

We will have the button be somewhat see-through. From the Rendering Mode menu in the Inspector, select “Transparent”.

In the Color window, set the alpha of ButtonMaterial to 147.

We will have the button contain some text. Right-click on “Cube” in the Hierarchy. Select 3D Object > 3D Text. “New Text” will appear in the Hierarchy. The text “Hello World” will appear in the Scene.

Set the X Scale value of New Text to 0.5. In the Text Mesh component, set Anchor to “Middle center” and Alignment to “Center”.

Set the text to sit just in front of the cube by changing its Z position to -0.7. Change Font Size to 15. In the Text property of Text Mesh, change “Hello World” to “Btn” (a shortened form of “Button”).

The text “Btn” will be of poor quality in the Scene. To correct this, scale down New Text in the Transform component. Then increase its font size in the Text Mesh component.

As such, the button’s text will be of better quality. Rename New Text “Label”. Rename Cube “Button”. Want to learn more? Check out our Unity3D course, where you build 30 virtual reality games!

Mammoth Interactive Favicon

Why you NEED to take this course :

Get in Touch.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

EMAIL US

support@mammothinteractive.com