This commit is contained in:
CortexCore
2024-12-27 21:46:57 +08:00
parent edb9008ae9
commit adb56d3023
9 changed files with 415 additions and 38 deletions

View File

@@ -10,6 +10,8 @@ namespace BITKit.UX
{
public class UXToolTips:IDisposable
{
public static VisualElement Hovering;
private readonly IUXService _uxService;
private readonly IMainTicker _ticker;
@@ -40,7 +42,12 @@ namespace BITKit.UX
}
if(_label is null || _rootVisualElement is null)return;
if (_label is null || _rootVisualElement is null)
{
Hovering = null;
return;
}
var tooltip = CurrentToolTip(_rootVisualElement.panel);
if (tooltip != "")
{
@@ -71,12 +78,18 @@ namespace BITKit.UX
{
// https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-faq-event-and-input-system.html
if (!EventSystem.current.IsPointerOverGameObject()) return "";
if (!EventSystem.current.IsPointerOverGameObject())
{
Hovering = null;
return "";
}
var screenPosition = Mouse.current.position.ReadValue();
screenPosition.y = Screen.height - screenPosition.y;
VisualElement ve = panel.Pick(RuntimePanelUtils.ScreenToPanel(panel, screenPosition));
Hovering = ve;
return ve == null ? "" : ve.tooltip;
}