"Should not be capturing when there is a hotcontrol" warning breaks the drag and drop in my UI.

Some context:
I am using 2022.1.23f1
I am building game UI not editor UI.
I’ve got an in-game drag and drop implementation which captures the mouse on MouseDown and releases it on MouseUp.
Sometimes when running my game in the editor, I get the following warning:
Should not be capturing when there is a hotcontrol
when this happens, I stop getting mouse events and, in particular, never get the mouse up event. I am really counting on getting that mouse up–that’s why I capture the mouse in the first place. Because I don’t get the mouse up I never get a chance to clean up the drag operation and my UI ends up in a pretty broken state.

Note that so far in my testing I don’t see the same failure in a build. However it is super annoying because I have to restart any test I am running under the editor when it happens.

Some questions:

  1. What is a hot control? How do I know when there is one?
  2. Is there a way for CaptureMouse() to return an error so I know this happened and can clean up?
  3. I really need a contract where after I get a mouse down I always get the corresponding mouse up, or at least some termination for the gesture. What is the right way to do this?

I get this in the editor a lot, too. It appears that sometimes part of the editor UI will capture the mouse pointer and not release it when entering play mode. Usually I can “fix” it by clicking around in the editor (e.g. drag a pane a little bit) and then back to the game window.

1 Like

Yes it’s pretty random and it happens A LOT… slow down the development significantly.

See this funny Unity Answer thread: Should not be capturing when there is a hotcontrol - Unity Answers