The question is quite simple, Is it possible to add extra variables to a button, for example, if I have multiple buttons, could I add some sort of ID for each button?
I’m asking this since I am trying to make some sort of an inventory system and what I have in mind would work perfectly if I’d be able to access buttons individually by IDs.
EDIT: here’s the code I already have:
var Icon : Texture2D = null;
var invOffset : float = 50;
var windowRect : Rect = Rect (10, 10, (200), (200));
var invButton : boolean = false;
function OnGUI ()
{
invButton = GUI.Toggle(Rect((Screen.width/2),(Screen.height-20),100,20),invButton, "Inventory");
if(invButton)
{
GUI.Window (0, windowRect, makeSlots, "Inventory");
}
}
function makeSlots ()
{
for(var x : int = 0; x < 5; x++)
{
for(var y : int = 0; y < 5; y++)
if (GUI.Button (Rect (x*40,y*40,30,30), Icon))
{
print ("clicked the button on row and column: " +(y+1) +(x+1));
}
}
GUI.DragWindow (Rect (0,0,10000,10000));
}
So basically all that I would need to have is a list of all items, and a way to see in which slot they are(if in any). Or at least thats all I think I need…