Mouse down event is detected after Input.GetMouseButtonDown

Hello,

I am currently developing a puzzle game which takes place on two fields. The fields are two viewports, the border between those viewports is a UI element. The user can adjust the viewport’s sizes by dragging that border. Also the user can pan each board by clicking and dragging the fields themselves.

7584364--940192--splitter.jpg

The dragging of the border is realized via UITK events while the panning of the fields is done within an update method using the old input polling.

Since the Event generation always takes place first (EventSystem comes before Default Time in the execution order), I assumed that it should be good to disable the panning behavior whenever the border UITK element receives the mouse down event to prevent the field from panning while the border is dragged.

7584364--940198--scriptexec.jpg

Sadly that does not work like that.
This is what happens:

  1. The panning behavior reads that the mouse button is down and switches to panning mode
  2. The mouse-down-event is received on the border → The panning behavior is disabled
  3. The mouse-up-event is received on the border → The panning behavior is re-enabled
  4. The field pans without any button being pressed since the panning behavior is in panning mode and waits desperately for the mouse button to be released

7584364--940201--logs.jpg
^ The input management is a state machine; when the default update behavior detects the mouse down, the input manager switches to the panning behavior (panning mode).

I think it is a bug that the UI events are only generated after the update methods have been executed.

BR,

Andrej


Update: I switched the Update() method for a LateUpdate() method. It now works as expected. But this also means, that the UI events are being generated between Update() and LateUpdate(). This lifecycle diagram should be updated with the event systems. Or is this documented elsewhere?

Hello! Can you give some insight on order of UI-event calculation and the Update() methods of behaviors?

BR,

Andrej

Hello, It’s me again. Some time has passed, can you point me towards some documentation on this? I don’t know whom else I should ask.
Thanks,
Andrej

I’ve also experimentally discovered UIToolkit events fire between Update() and LateUpdate(), which wasn’t expected and our engine is update-order sensitive.

I’m nervous that this is undocumented behavior and concerned that it may not always be the case.