How can I have my tooltip popup adjust its position if it’s drawning off screen?
Coding in C#.
if (hoveringOverPlace == true)
{
//Vector3 pos = hoveringPlace.transform.position;
Rect windowRect = new Rect(Input.mousePosition.x+20,
Screen.height-Input.mousePosition.y - 60, (Screen.width / 2) - 500, (Screen.height / 2) - 300);
windowRect = GUI.Window(0, windowRect, PlaceInfo, hoveringPlace.name);
}
}
void PlaceInfo(int windowID) {
GUI.Label(new Rect(10, 20, (Screen.width / 2) - 500, (Screen.height / 2) - 300), wrapString(labelText, 300));
}
Umresh
2
Try this works only if tooltip disappears offscreen in horizontal outside screen is a bool
if (Input.mousePosition.x < Screen.width && Input.mousePosition.x > 0) {
windowRect = new Rect (Input.mousePosition.x,
Screen.height - Input.mousePosition.y - 60, (Screen.width / 2) - 500, (Screen.height / 2) - 300);
outsideScreen = false;
}
else if(Input.mousePosition.x >= Screen.width && !outsideScreen)
{
windowRect = new Rect(windowRect.x,
Screen.height-Input.mousePosition.y - 60, (Screen.width / 2) - 500, (Screen.height / 2) - 300);
outsideScreen = true;
}
else if(Input.mousePosition.x <= 0 && !outsideScreen)
{
windowRect = new Rect(windowRect.x - (windowRect.width),
Screen.height-Input.mousePosition.y - 60, (Screen.width / 2) - 500, (Screen.height / 2) - 300);
outsideScreen = true;
}
windowRect = GUI.Window (0, windowRect, PlaceInfo, "ToolTip");
}