internal static void SetTooltip(float mouseX, float mouseY) { //mouseX,mouseY are screen relative. GUIView view = GUIView.mouseOverView; if (view != null && view.visualTree != null && view.visualTree.panel != null) { var panel = view.visualTree.panel; // Pick expect view relative coordinates. VisualElement target = panel.Pick(new Vector2(mouseX, mouseY) - view.screenPosition.position); if (target != null) { using (var tooltipEvent = TooltipEvent.GetPooled()) { tooltipEvent.target = target; tooltipEvent.tooltip = null; tooltipEvent.rect = Rect.zero; view.visualTree.panel.dispatcher.DispatchEvent(tooltipEvent, panel); if (!string.IsNullOrEmpty(tooltipEvent.tooltip)) { Rect rect = tooltipEvent.rect; rect.position += view.screenPosition.position; //SetMouseTooltip expects Screen relative coordinates. GUIStyle.SetMouseTooltip(tooltipEvent.tooltip, rect); } } } } }
internal static void SetTooltip(float mouseX, float mouseY) { GUIView mouseOverView = GUIView.mouseOverView; if (mouseOverView != null && mouseOverView.visualTree != null && mouseOverView.visualTree.panel != null) { IPanel panel = mouseOverView.visualTree.panel; VisualElement visualElement = panel.Pick(new Vector2(mouseX, mouseY) - mouseOverView.screenPosition.position); if (visualElement != null) { using (TooltipEvent pooled = EventBase <TooltipEvent> .GetPooled()) { pooled.target = visualElement; pooled.tooltip = null; pooled.rect = Rect.zero; mouseOverView.visualTree.panel.dispatcher.DispatchEvent(pooled, panel); if (!string.IsNullOrEmpty(pooled.tooltip)) { Rect rect = pooled.rect; rect.position += mouseOverView.screenPosition.position; GUIStyle.SetMouseTooltip(pooled.tooltip, rect); } } } } }
private void OnTooltip(TooltipEvent e) { e.tooltip = this.tooltip; e.rect = base.worldBound; e.StopPropagation(); }
void OnTooltip(TooltipEvent e) { e.tooltip = tooltip; e.rect = worldBound; e.StopPropagation(); }