Hi folks, quick question. I understand this might be out of scope for the purposes of the OnGUI system, but I’m having a hard time understanding how a GUI.tooltip is assigned to a button.
The example given from the manual is as follows:
void OnGUI () {
// This line feeds "This is the tooltip" into GUI.tooltip
GUI.Button (new Rect (10,10,100,20), new GUIContent ("Click me", "This is the tooltip"));
// This line reads and displays the contents of GUI.tooltip
GUI.Label (new Rect (10,40,100,20), GUI.tooltip);
}
Which doesn’t make sense to me because how does the second statement know which button to assign the tooltip to? What if there are two buttons?
For example:
void OnGUI()
{
//Button #1
GUI.Button(new Rect(10, 10, 100, 20), new GUIContent("Click me", "This is the tooltip"));
GUI.Label(new Rect(10, 40, 100, 20), GUI.tooltip);
//Button #2
GUI.Button(new Rect(10, 120, 100, 20), new GUIContent("Click me #2", "This is the tooltip #2"));
GUI.Label(new Rect(10, 160, 100, 20), GUI.tooltip);
}
In the above case, if I hover over the first button, I see both tooltips underneath both buttons with the text from the first tooltip.
And if I hover over the second button, I see only the second tooltip under the second button only. That is very strange behaviour.
Any tips on this? I haven’t been able to find anything regarding this, no examples in neither manual or script reference, and no google hits.