I’ve got a GUI.Label which shows a Texture2D. I want it so when user hovers his mouse over the picture a window pops up where the mouse cursor is. Is something like this possible?
I’ve seen a OnMouseOver function, but as far as I understood it only works when you add a script with it to an existing gameObject. My labels are generated by script - depending on how many items are in the inventory.
i recently implemented something like this in one of my programs, i used Rect.Contains code, but i ran into a problem with the input.mouseposition.y being all weird, anyways try this:
Rect myRect = new Rect(100, 100, 20, 20);
void OnGUI()
{
GUI.Label(myRect, "random texture");
if(myRect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)
{
GUI.Box(new Rect(x, y, width, height), "random message");
}
}
it uses the rect position to determine if the mouse is on the gui.label then draws a box if its true