Quantcast
Channel: Answers for "how to get menu content id on mouse hover in c#?"
Viewing all articles
Browse latest Browse all 4

Answer by CorruptedTNC

$
0
0
You can set your button (or any other GUI element) to have "GUIContent" when you create it in OnGUI(). In one of my projects I have this: if(GUILayout.Button (new GUIContent(obj.name, string.Format("Name: {0}\nCost: {1}\n{2}", po.Name, po.Cost, po.Description))) And then later on I pull the information for a tooltip style menu item: GUI.Label(new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y, 200, 100), GUI.tooltip); While this may not be exactly what you want, you can store whatever information you like in there. It may not be the most elegant solution but you could store an ID, name and value in the tooltip like so: if(GUILayout.Button(new GUIContent("1|start|false"))) and then later on get that information and split it using the character '|' like so: string[] info = GUI.Tooltip.Split('|'); and from there convert it to whatever type you want.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images