-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTooltipGUI.cs
45 lines (38 loc) · 1.45 KB
/
TooltipGUI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using UnityEngine;
namespace UnityGameUI
{
internal class TooltipGUI : MonoBehaviour
{
public static TooltipGUI instance = null;
public static bool EnableTooltip = true;
public static string Tooltip = "";
private static GUIStyle tooltipStyle;
private static bool fired = false; // 调试信息
public TooltipGUI()
{
//BepInExLoader.log.LogMessage("TooltipGUI Loaded");
instance = this;
}
public void OnGUI()
{
if (!fired)
{
Debug.Log("TooltipGUI OnGUI Fired");
fired = true;
}
if (Tooltip != "" && EnableTooltip == true)
{
GUI.backgroundColor = Color.black;
GUIContent content = new GUIContent(Tooltip);
tooltipStyle = new GUIStyle(GUI.skin.box);
tooltipStyle.normal.textColor = Color.white;
float width = tooltipStyle.CalcSize(content).x;
float height = tooltipStyle.CalcSize(content).y;
var mousepos = UnityEngine.Input.mousePosition;
//var mousepos = EventSystem.current.currentInputModule.input.mousePosition; // Instead of Input.mousePosition
GUI.Box(new Rect(mousepos.x + 15, Screen.height - mousepos.y + 15, width, 25), content, tooltipStyle); // The +15 are cursor offsets
}
}
}
}