OnClick Events in Unity
Using Unity UI Buttons to Interact with the Player
When Creating a UI in Unity you can add a Button.
The Button control responds to a click from the user and is used to initiate or confirm an action. Familiar examples…
In order to Interact with the Button Unity Provides a On Click Unity Event that you can register to.
UnityEvents are a way of allowing user driven callback to be persisted from edit time to run time without the need for…
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.