OnClick Events in Unity
I’m working with the UI of the mobile project for the management of the shop I’ve realized a system that allows you to select an item on the screen and buy it by pressing the “Buy Item” button.
To realize the selection and the purchase the use of the unity system linked to the inspector for the management of OnClick events is essential.
I can realize simple script functions associated with a GameObject in the scene and then insert it as behavior inside a button of my UI.
Let me explain, in my script I have written a function.
You have to select the GameObject with the assigned script and insert it in the listener of the button, the methods to be visible must be public.