Skip to content
This repository was archived by the owner on Aug 7, 2019. It is now read-only.

UnityAdsHelper Button

Nikkolai Davenport edited this page Jun 10, 2016 · 3 revisions

Unity UI Button

In this section, we'll create and configure a Unity UI Button for use with this example.

Step 1: Start by creating a new Unity UI Button in your scene. Creating a new UI Button will also add a UI Canvas and EventSystem to your scene if they don't already exist.

  1. Select GameObject > UI > Button from the Unity Editor menu.
  2. Press the T key to switch to using the Rect Transform Tool.
  3. Select and drag the UI Button to the center of the UI Canvas.

Step 2: Customize the UI Button for use with this example.

  1. Rename the new UI Button to ShowAdButton.
  2. Expand ShowAdButton in the Hierarchy to view child objects.
  3. Locate and select the GameObject named Text.
  4. Rename the Text GameObject to ReadyText.
  5. Enter "Show Default Ad" into the Text field of the Text component.

Example Scene

Step 3: Create a non-interactable version of the button text.

  1. Locate and select the GameObject named ReadyText.
  2. Select Edit > Duplicate to create a duplicate GameObject.
  3. Rename the duplicate GameObject to WaitingText.
  4. Enter "Waiting..." into the Text field of the the Text component.
  5. Disable the Text component of the GameObject for the time being.

Example Hierarchy Example ReadyText

Step 4: Configure the UI Canvas to scale with screen size.

  1. Locate and select the GameObject named Canvas.
  2. Set the UI Scale Mode of the Canvas Scaler to Scale With Screen Size.
  3. Set the Match value to 0.5 between Width and Height.

Example Canvas Scaler

Note: Be sure to check out the Unity UI system Tutorials and Docs to learn more.

Clone this wiki locally