Hi all. I have multiple buttons in a window. I know how to write the tooltips and it works fine when I only assign one tooltip but when I move on to the next button and assign a new tool tip there it breaks and I get varied results.
Here is the code:
if (LootItem1 != null)
{
slot1 = LootItem1.GetComponent("Item");
if (GUI.Button(Rect (60,120,60,60),GUIContent("",ToolTipText1),GUIStyle (ButtonOne)))
{
if (cinventory[0] != null)
{
Inventory.statInventory.AddItem(cinventory[0]);
cinventory[0] = null;
}
}
if (cinventory[0]!= null)
{
GUI.DrawTexture (Rect(65,125,50,50),cinventory[0].itemtex);
GUI.Label (Rect (115,10,120,120), GUI.tooltip, GUIStyle (ToolTipStyle));
}
}
This works fine but when I add the next code:
if (LootItem2 != null)
{
slot2 = LootItem2.GetComponent("Item");
if (GUI.Button(Rect (150,120,60,60),GUIContent("",ToolTipText2),GUIStyle (ButtonTwo)))
{
if (cinventory[1] != null)
{
Inventory.statInventory.AddItem(cinventory[1]);
cinventory[1] = null;
}
}
if (cinventory[1] != null)
{
GUI.DrawTexture (Rect(155,125,50,50),cinventory[1].itemtex);
GUI.Label (Rect (115,10,120,120), GUI.tooltip, GUIStyle (ToolTipStyle2));
}
}
It breaks. By Break I mean its supposed to disappear when the slot is empty. With only one tootip defined it does just that. With both defined it does not go away. Also it seems to try and write both styles for the first one and one for the second. I should mention this is NOT in the ONGUI function but in a window of its own. I tried defining the tooltipstyle with the same style and got even more bizzare behavior. Anyone see the obvious problem here that I must be overlooking?