I’m having trouble getting GUI.tooltip to work well with GUI Windows and GUILayout. There are two issues:
- It seems that GUI.tooltip is only valid inside the Window’s GUI function, but I need to be able to show a tooltip that extends outside the boundaries of the Window.
- The tooltip needs to display even if the window is not focused.
Because I’m using GUILayout instead of GUI, I can’t check if the mouse position is inside the component’s rectangle.If anyone could show me how to get the below code working, it would be hugely appreciated!
using UnityEngine;
public class App : MonoBehaviour {
Rect win1Rect = new Rect(20, 20, 150, 150);
void OnGUI () {
GUILayout.BeginArea(win1Rect);
win1Rect = GUI.Window(0, win1Rect, DoWin1, "Win1");
GUILayout.EndArea();
if (GUI.tooltip != "") {
// Does not work because it's outside of DoWin1
GUI.Label(new Rect(0, 0, 100, 20), GUI.tooltip);
}
}
void DoWin1 (int windowId) {
GUILayout.BeginVertical();
GUILayout.Button(new GUIContent("Button", "Win1 tooltip"));
GUILayout.EndVertical();
}
}