Creating a UI canvas and button

In Unity, user interface (UI) buttons reside on a canvas. Create a canvas:

  1. In Hierarchy, select Create | UI | Canvas.
  2. Select Canvas and change UI Scale Mode to Constant Physical Size.

By default, the Canvas UI Scale Mode is set to Constant Pixel Size. This is an issue since mobile devices can have many different screen sizes and density (DPI), and your buttons will get smaller or bigger depending on the screen size. We will change it to Constant Physical Size.

You can then arrange your UI on the canvas as you desire. Create and position a button in the lower right-hand corner of the screen.

  1. With the Canvas selected, right-click on UI | Button.

The button is easily previewed in the Game window. In Inspector ...

Get Augmented Reality for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.