UI in Unity
Building UI in Unity is amazingly powerful and easy.
Start by right clicking in the hierachy, go to UI, and select Canvas
In the Canvas game object you’ll find:
A Rect transform, a sub type of transform that all UI elements use.
A Canvas defining how the canvas is integrated into the application.
A Canvas Scaler, defining how the UI should react to changing screen sizes.
And a Graphics Raycaster allowing you to register clicks on the canvas.
The first thing I recommend doing is changing the Canvas Scaler from its default behavior of “constant pixel size” to “scale with screen size”. This will, as the name implies, make the application rescale the UI to fit the screen. I usually choose a reference resolution of 1920 x 1080 if what I'm working on is intended for landscape orientated screens because most consumer devices have at least that high a resolution.
Here I have a score display that I want to put in the top right corner of the screen. While I could simply move it up there from its default anchor and position, Unity provides a generous set of presets, able to set anchor, position, pivot, and even size of the UI object.
Here I have selected the top right anchor point and set the position relative to that anchor point.
While there is of course more to UI in Unity, this is best explored through other documentation dedicated to those individual aspects.