How to create a button with a tooltip

Hello,

I know how to create a button that executes code when clicked and I know how to create a button with a tooltip but when I try to add a tooltip to a clickable button in the code it breaks :-(

How do I put those two things together? (The if statement and the tooltip class)

Thanks for your time,

you should set the tooltip in a GUIContent and then use the GUI.tooltip property to get the tooltip and display it in a label. the GUIContent is the first parameter in GUILayout functions and the second in GUI.xxx functions.

if (GUI.Button (Rect(10,10,100,60,GUIContent("button name","tooltip text"))))
{
//execute click event code
}
GUI.Label (Rect(300,300,100,100),GUI.tooltip);

great ashkan, here is unbug version

if (GUI.Button (Rect(10,10,100,60),GUIContent("button name","tooltip text")))
{
print(  " okok  "  );
}
GUI.Label (Rect(300,300,100,100),GUI.tooltip);

i am using the more than one button in the OnGUI() function if i use this which is you gave above, my all tooltip name showing the same one.