I also encountered this problem.
After debugging and testing, I have identified the root cause.
When we press above the UI, it usually does not trigger the event after Pressed for touch input. The events after Moved and Released naturally cannot be triggered.
A special case: When this UI is a Slider, pressing does not trigger Pressed, but dragging briefly triggers a few frames of Moved event!
Due to my camera’s interaction, Pressd is triggered when pressed, storing a mouse position in a variable, Moved is triggered when dragged, and the difference between the latest mouse position and the recorded mouse position is added to the camera’s rotation. Then update the recorded mouse position with the latest mouse position, and use this loop to drive the camera rotation.
Therefore, when interacting with the slider, the event after Pressed is not triggered and the latest mouse position is not recorded, while dragging triggers the event after Moved. At this time, the latest mouse position and the position at the end of the last drag will be subtracted and added to the rotation of my camera. Causing a brief camera rotation when I drag the slider
This may be an issue with the source code of the Slider component. I am not a programmer and do not understand how to read the source code. If it is a bug, I hope the official can fix it as soon as possible.
My current solution is to enable a Tick event before using the slider, and keep updating the mouse position recorded in the Pressed event. When dragging the slider triggers a brief Moved exception, the camera will hardly rotate because the latest mouse position is equal to or very close to the one I recorded. Of course, this method may bring some performance issues. Let’s use it temporarily before considering optimization solutions.
You can also solve this problem based on the actual situation of your camera interaction, hoping to help you.
——————————————————————————————————————————————
Update:
The temporary use of the Tick event method mentioned above can only be done in the editor. It is effective when the project settings are checked to simulate touch with a mouse, and it is useless after packaging (because touch screens do not have movement trajectories like mice).
The good news is that I found a better way today (cleverly utilizing the BUG feature of the slider component):
Just add a Boolean variable. I named it ‘A’ and set it to true by default.
Add a branch judgment after the Moved event. If A is true, no action will be taken. If A is false, the original event (such as moving or rotating the camera) will be triggered normally.
After the Pressed event, set A to false.
After the Released event, set A to true.
Okay, now let’s sort out the logic:
Firstly, there is a situation where operations are not performed on the UI. Pressing it will trigger the Pressed event, setting A to false, so when moving, it can trigger camera rotation and movement normally. When the touch is released, A is set to true again.
Then there is the situation of operating on the slider. According to previous tests, it is known that when the touch is pressed on the slider, the Pressed event after input Touch will not be triggered. Therefore, the Boolean variable A will remain at its default value (true). Dragging the slider at this time will briefly trigger the Moved event. Since the value of A is true, no subsequent movement or rotation of the camera will be performed, but the slider can be dragged normally. Leaving touch will not trigger the Released event, but A will still remain true.
Afterwards, I tested it on the packaged Android device and it was also normal. I think this should be a solution before the official fix of this issue. (The engine version I am using is 5.6.1)