- Home /
Help with GUILayout and tooltip(C#)
Okay so, I really suck at UI programming. It just kind of hits me like a brick wall and stalls my progress for days every time I have to do it. I see nothing wrong with my code, and I am getting no errors, but the tooltip will NOT show up.
What am I doing wrong? (I do have an inventory system already set up, and the names show up properly.)
void OnGUI()
{
int tempinv = 0;
GUILayout.BeginArea (new Rect(30, 30, 500, 500));
foreach(GameObject items in inventory)
{
GUILayout.Button ( new GUIContent(inventory[tempinv].GetComponent<Item>().name, "\n" + inventory[tempinv].GetComponent<Item>().tooltips.text), GUILayout.Width (500), GUILayout.Height (50));
}
GUILayout.Label (GUI.tooltip);
GUILayout.EndArea ();
}
Answer by clunk47 · Jul 22, 2013 at 08:07 PM
Remove the newline character "\n" and it should work. No need for the new line because the text on the button and tooltip will be in separate areas.
That worked, although, I have newlines in my actual tooltip and it's only showing the first line. Should I make the label a larger rect, like the other person said?
I only added the newline because previously it wouldn't work properly without it, but that was before I added the gui.tooltip line.
Edit: i figured it out, sort of, so, I'll stop bugging!