OnClick Events in Unity
Objective: Set up Shop Items Select-On-Click
The above shop system was created by first adding a Canvas to the hierarchy. Then a selection of background images, buttons and text elements were added and positioned to give the above display.
Each button has the ability to run OnClick events which can be assigned in the inspector after selecting a button. An event can then be assigned which can call a method from within a chosen script. As seen below the OnClick event calls the Shop_Keeper script and calls the SelectItem method and passes the necessary integer value that was set up on the method. This SelectItem method is then used with a switch statement to update the UIManagers selection and some global variables which can be used to purchase the selected item if the Player has enough gems.