Hi, I’ve been using the UI-Toolkit for about a month now, and have become fairly competent with it, but trying to do anything with positions at runtime is a nightmare for me.
Currently, I am trying to display a Tooltip-like visual element at the mouses position when you hover over a different element. This works fine when the editor is in full screen, but when I resize it or run a build the position is completely off.
When debugging the mouse pos, it seems correct, but the location where the tooltip VisualElement is placed is completely wrong. The smaller the screen size gets, the farther off to the left the tooltip appears.
Here is the code I am currently using, and my Panel Settings:

Any suggestions or known ways of doing this?
While debugging, noticed that the RuntimePanelItols.ScreenToPanel() line isn’t changing the pos values at all.
Still do not have a solution for my problem though.
I’ve had more success with RuntimePanelUtils.CameraTransformWorldToPanel
myself. I currently use it for having a UI cursor follow the (hidden) mouse cursor.
Code is simply:
private Vector3 GetReticuleScreenPosition()
{
Vector3 position = Reticule.GetReticuleWorldPosition();
return RuntimePanelUtils.CameraTransformWorldToPanel(_root.panel, position, _camera);
}
Does require having a reference to the camera to pass through.
Thank you for the response. I still didn’t see the correct positioning after trying your method, but I did just figure out a work-around to my issue.
I made a separate UIDocument to place the tooltips on with a different panel settings asset that was using Constant Pixel Size. This keeps the rest of the UI scaling properly, but allows my tooltips to be positioned correctly as well.
The only issue with my work around is that the tooltips do not scale according to screen size which means they are quite large when in a smaller window. Luckily it is just this one feature and I can probably manage to hardcode a way to make it a better size.
Thanks, again!