- Home /
Question by
ExhaustedPiggy · Feb 14, 2012 at 06:41 AM ·
guibuttontooltip
How to assign a different tooltip to each GUI button?
In Unity's GUI Basic Guide, the follow code shows how to assign a tooltip to a button:
// This line feeds "This is the tooltip" into GUI.tooltip
GUI.Button (Rect (10,10,100,20), GUIContent ("Click me", "This is the tooltip"));
// This line reads and displays the contents of GUI.tooltip
GUI.Label (Rect (10,40,100,20), GUI.tooltip);
Now I want to assign two different tooltips to two buttons. I did that like this:
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);
GUI.Button(new Rect(150, 10, 100, 20), new GUIContent("Click Another", "This is another tooltip"));
GUI.Label(new Rect(150, 40, 100, 20), GUI.tooltip);
When the mouse hovered over the first button, I got both "This is the tooltip" and "This is another". How to assign the second tooltip "This is another tooltip" to the second button? Thank you!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613064054im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Generating tooltips for multiple buttons. 1 Answer
Why is a tooltip ignoring a Rect and not another? 1 Answer
Tooltip does not show 1 Answer
How to add intermediate tooltip to GUI button? 1 Answer
Button Turns Off and On Object 1 Answer