Okay, I HATE GUI coding. It makes VERY little sense to me, so PLEASE tell me what I"m doing wrong
If you hover over the first item in the array with 2 items in it (haven’t tried with more) it gives you double the tooltip, but the second item in the array works properly.
void OnGUI()
{
if(inventoryOpen)
{
int invcount = 0;
GUI.BeginGroup (new Rect(Screen.width/2 +100, Screen.height - 200, 400, 100));
GUI.Box (new Rect(0,0,400,100), "Weapons");
foreach(GameObject inv in inventory)
{
if(invcount < inventory.Count)
{
invcount ++;
}
if(GUI.Button (new Rect(10 + (invcount - 1) * 65,20,60,60),new GUIContent(inv.name, "Damage: " + inventory[invcount-1].GetComponent<Item>().dmg)))
{
Debug.Log ("equipping" + inv.name);
//Write this later
}
GUI.Label (new Rect(10 + (invcount - 1) * 65, 70, 100, 30), GUI.tooltip);
}
GUI.EndGroup();
}
}