Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Styling tooltips

Discussion in 'UI Toolkit' started by TheValar, May 6, 2020.

  1. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    Is it possible to assign a style-sheet to the tooltip that comes up when you assign the tooltip property is UXML?
     
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    Assuming this is for the Editor, no that is not possible. You could override the behaviour of the Tooltip event though:

    1. Register callback for
    TooltipEvent
    on an element or on the root of your UI
    2. Call event.PreventDefault() to prevent the builtin display of tooltip
    3. Retrieve the event.tooltip string corresponding to the element which was under the mouse and make a custom display for it. For example add an element on top of everything and make it
    style.position = Position.Absolute
    and
    pickingMode = PickingMode.Ignore


    The trickiest bit would be manage delay and mouse movement.
     
  3. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    thanks for the answer. Too bad it's not officially supported seems like something most people styling their editor windows would want to do. Thanks for the workaround though.