Buttons
One of the most common UI elements is a simple button. Pretty much all UI interfaces on the most commonly available Unity platforms contain buttons. The simplest interaction with a button is a click. You will now learn how to construct a button in Unity UI and call a certain method in the code when the button is clicked on.
To speed up your learning process, I have prepared ready-to-use UI elements.
Download and import MenuViewUIElements.unitypackage
into your Unity project, as follows:
Unity will import a few useful assets with this package. In the Project View, find Prefabs/UI/PlayButton.prefab
and drag it directly on top of the Menu Canvas, as shown here:
When you drop the prefab, the PLAY button should appear on the canvas, like this:
A simple button
Before we talk about the functionality of the button, we will talk about the visual parts that make up the simple labeled button:
Image
Unity can very easily draw 2D images on the UI canvas. Select your button and take a look at the Inspector...