- Home /
How to make Image Clickable for Inventory.
Hello And Recently I have been building an inventory system for a small little game that I have been making. Unfortunately I want to make it that when I click an image it knows which image it is and what slot it is on so that I can use the item in that specific slot. I have not had luck on Youtube in finding something that would fit what I need. I would love to know how I could make a clickable Image/Slot in my inventory so I may continue on with my game. Thank you for taking the time in helping me.
Answer by xvivax · Sep 22, 2017 at 03:08 AM
Hi, To make image clickable you just need to add button component on it and that's it :)
Regarding tracking slots, there is different solutions for different approaches. For example you can give each slot unique id and then use that id to check which slot it is: if(id == 2) then this is slot2.. and so on. Or you can use OnClick() function which came with button component, just create public void function and add it to this function.
Hi. Thank you for answering. I placed a button under the image which worked. Now when I click the button and lets say it identifies it I want it to check for that specific slot in my loop if it has that item. Cause at the moment my loop to check my inventory just starts at 0-9 but I want it to check only the slot I clicked. Do you happen to have a video or an example that you could show me. Other than that tank you for the help.