Using OnClick Events in Unity

2D Mobile Game

Objective: Create an OnClick event for the shop.

Create a switch case and define what each case does which in this case define the selected item and define the highlight position

Then when you press on buy item, the script will buy the one that was selected and remove gems with respect to the item and if the gem count is lower than the item price then the item is not bought.

Now in the inspector, select the UI Button and drag the gameobject where the script with cases were defined are stored and select the method which will respond to the button press.