Video material

Get Help
Overview: Watch how easy it is to create UI elements in Unity.

What You'll Learn:

  • Core concepts and fundamentals
  • Setting up your development environment
  • Best practices and workflows
  • Common pitfalls and how to avoid them

Overview

Summary: This lesson covers UI basics in Unity, including canvas setup, panel and button creation. Learn how to enable GameObjects when UI buttons are pressed.

Button Reference

Assigns a UI button to trigger the action

Target GameObject

Specifies which GameObject to enable when button is pressed

Initial State

Ensures target object starts disabled on scene load

Button Listener

Adds onClick listener to enable object when button is clicked

Code Example

Get Help
EnableObjectOnButtonPress.cs
MonoBehaviour

Description: A simple script that enables a GameObject when a UI button is pressed.

Loading code...

How to Use

Setup Instructions:

Step 1: Create UI Button

Create a UI Button in your Canvas (Right-click Canvas > UI > Button).

Step 2: Create Target GameObject

Create the GameObject you want to enable (e.g., a Panel, Image, or Text).

Step 3: Attach Script

Create an empty GameObject and attach the EnableObjectOnButtonPress script to it.

Step 4: Assign References

In the Inspector, drag your Button to Target Button field and your GameObject to Target Object field.

Step 5: Test

Press Play and click the button to enable the target GameObject.

Important Notes:

  • The target object will be automatically disabled when the scene starts
  • Make sure both Target Button and Target Object fields are assigned
  • The script uses SetActive(true) to enable the object when button is clicked