Convert InputSystem event position to UI position

I was using PointerMoveEvent to get mouse/pen movement, but the resolution was too low (locked to framerate I believe), so I switched to using InputSystem.onEvent. But the positions I’m getting from these events are confusing. If I have a pointer position from one of those low-level events, how do I get the position relative to a UI element in an EditorWindow?

At runtime, I found RuntimePanelUtils.ScreenToPanel() and that seems to work. But when not in play mode, in a Unity EditorWindow, I’m not understanding what these positions are relative to. Without going into complicated details yet, it seems like they vary based on whether or not the Game window is open in Unity, among other things. I just need something relative to my own EditorWindow and I could work with that.

It seems like the UIToolkit team must have solved this problem because the positions I get from PointerMoveEvent are relative to my own UI space. Is there a EditorPanelUtils API somewhere?

On second thought I think this is probably handled in InputSystem before it reaches the UI code. I’ll ask over on their forum I guess. Feel free to correct me if I’m wrong though.

Maybe this would help you: Using the Input System in the Editor | Input System | 1.0.2

But yes, the input system forum would be a better place to answer this :slight_smile:

Thanks, yeah I did see that…unfortunately the onEvent handler does not seem to get that coordinate translation. I think it might be possible to do the translation using reflection to get the GameView window’s position, but surely there’s a better way.