Im trying to create an inventory system but im not having to much success. Im trying to figure out how to add a texture to an already created button if a variable is true. Can anyone help? Here is my code for opening the inventory:
var Inventory = new Array();
var emptySlot : Texture;
var showInventory = false;
var ex1 : float = 2.8;
var why1 : float = 5.8;
var exBig : float = 200;
var whyBig : float = 200;
var ex2 : float = 2.8;
var why2 : float = 5.8;
var sword = false;
var swordTexture : Texture;
function Update ()
{
Debug.Log(Inventory.length);
if (Input.GetKeyDown(""))
sword = true;
}
function OnGUI ()
{
if (GUI.Button(Rect(Screen.width-100, Screen.height/2-50, 100, 100), emptySlot))
{
if (!showInventory)
{
showInventory = true;
}else{
showInventory = false;
}
}
if (showInventory)
{
GUI.Box(Rect(Screen.width/ex1, Screen.height/why1, exBig, whyBig), "Inventory");
for (var x=1; x<6; x++)
{
for (var y=1; y<6; y++)
{
if (GUI.Button(Rect(Screen.width/ex2+x*50, Screen.height/why2+y*50, 50, 50), emptySlot))
{
}
}
}
}
}
Is there a way to where if sword = true then it shows the sword texture in the first open slot?