- Home /
GUI.DragWindow causing Inventory Tooltip to stop showing
Hi there,
I have an Inventory Script which displays a tooltip if you hover over an inventory space containing an item.
However, today I introduced a GUI.DragWindow beneath it in order to make it look better and also to allow the user to move it around where they'd like it. The trouble is, the tooltip for hovering over an item is now no longer generated. It will display the background of the tooltip, but no content. I can enter text to be displayed in the tooltip box in the GUI.Box declaration for it, but if I just use the tooltip variable like I was before, it no longer shows anything.
The script is quite long so I've put it on pastebin.
This is the original and this is the new one.
I feel as if the problem lies within this line of code, because it's calling DrawInventory, whereas, when it was working, DrawInventory was called simply with DrawInventory();
windowRect = GUI.Window(0, windowRect, DrawInventory, "Inventory", skin.GetStyle ("MainGUI"));
After using Debug.Log to print out the tooltip and to ensure the methods were being called correctly, I can confirm tooltip IS being set to what it should, it's just not being displayed how/where it should be, so the box is blank.
It will also take another string variable and display that just fine, it seems to just be tooltip.
Success!
It turns out that when using the GUI.DragWindow to contain the Inventory, by the time the DrawTooltip method was being called, the tooltip variable was already being set back to nothing.
So I solved this by changing this:
Event e = Event.current;
tooltip = "";
GUI.skin = skin;
GUI.skin = dragSkin;
if(openInventory)
{
if(showTooltip)
{
DrawTooltip();
}
}
To this:
Event e = Event.current;
GUI.skin = skin;
GUI.skin = dragSkin;
if(openInventory)
{
if(showTooltip)
{
DrawTooltip();
tooltip = "";
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613182404im_/https://answers.unity.com/themes/thub/images/avi.jpg)