OnClick Events in Unity

Using Unity UI Buttons to Interact with the Player

James Lafritz
2 min readJul 17, 2021

When Creating a UI in Unity you can add a Button.

In order to Interact with the Button Unity Provides a On Click Unity Event that you can register to.

An Unity Event can run any public Method or Change any public Property on any GameObject Components in the Scene.

I have a method for Selecting an Item in my Shop and For Buying an Item in my Shop in my Unity Manager on my Canvas.

To assign these all I need to do is click the plus button on each of my Buttons On Click Event and select what I want to do.

Now when I click on the Buttons the On Item Selected and Buy Item will run.

--

--

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.