GUI only showing texture of the newest addition in the array. Help?

Hi all. 1st off, thanks to everyone that has helped me out a huge lot over the last few days. You guys really made my 1st steps into coding a lot more bearable than otherwise :slight_smile:

Ok, problem time:

function OnGUI()

{
for (var g : GameObject in InventoryGrid)
{
items= g.GetComponent(ItemIdentifier).ItemTexture;
}
GUI.skin = MenuSkin;
if (DisplayCharacter)

{
GUI.BeginGroup
(new Rect(Screen.width0.3,Screen.height0.1,Screen.width0.4,Screen.height0.8));

GUI.Box(Rect(0,0,Screen.width0.4,Screen.height0.8),“”);

for(i=0;i<InventoryGrid.length;i++)
{
GUI.Button(Rect(0+(i*Screen.width*0.05),0,Screen.height*0.05, Screen.height*0.05),items);
}

GUI.EndGroup ();
}

^ So, basically I’m made an array to display the Icons (ItemTexture) found within an Item Script (ItemIdentifier) of Objects from my array (Inventory Grid)

^In the 1st photo, my inventory is empty. In the next one, I’ve added 5 maces. In the third, I added a new item with a blank texture and all the previous 5 textures were cleared. However, when i added another mace, now all the textures are maces again.

My best guess is that you should set your Items texture in the same spot you use it,
ex

 if(show inventory)
    for(var i : int = 0; i < number of items in inventory; i++)
    {
    texture to use = item texture;
    GUI.Button(Rect(0+(i*Screen.width*0.05),0,Screen.height*0.05, Screen.height*0.05), texture to use);
    }

I think whats happening is that your item texture is being set to the last item in your inventory
-Everett