OnUseUsable being called after touch started over UI element
Posted: Tue Sep 14, 2021 3:54 pm
Hi,
Something annoying is happening in my game, and I wonder whether it is intended behaviour - and if so, if there is a built-in way to change it. It's easiest to explain with a screenshot: There are two relevant usables in this scene (ignore the TrashSlotPaperBall2 and the TrashSlotScarf near the top): the center collider has a usable which triggers a cinemachine camera transition to focus on this screen, and the four outer colliders revert to the standard camera shot when clicked. This is essentially a way to focus on the screen and zoom back out by clicking next to it.
Now, the issue is that the onUse of the external colliders is always called on mouseUp, which is likely intended behaviour and is usually fine. However, in this case it often happens that one is adjusting the volume slider (circled in red) and in doing so, moves the mouse over the rightmost collider. Then on mouseUp, the usable's onUse is triggered and the camera zooms out of the screen, which is unwanted behaviour.
Essentially what I need is for the onUse not to trigger on mouseUp, if the previous mouseDown happened over a UI element. This feels like something that may have a built in solution, so I thought I'd ask here first. If there is no built-in solution, what approach do you suggest? I suspect modifying the Selector class would be my best bet?
Something annoying is happening in my game, and I wonder whether it is intended behaviour - and if so, if there is a built-in way to change it. It's easiest to explain with a screenshot: There are two relevant usables in this scene (ignore the TrashSlotPaperBall2 and the TrashSlotScarf near the top): the center collider has a usable which triggers a cinemachine camera transition to focus on this screen, and the four outer colliders revert to the standard camera shot when clicked. This is essentially a way to focus on the screen and zoom back out by clicking next to it.
Now, the issue is that the onUse of the external colliders is always called on mouseUp, which is likely intended behaviour and is usually fine. However, in this case it often happens that one is adjusting the volume slider (circled in red) and in doing so, moves the mouse over the rightmost collider. Then on mouseUp, the usable's onUse is triggered and the camera zooms out of the screen, which is unwanted behaviour.
Essentially what I need is for the onUse not to trigger on mouseUp, if the previous mouseDown happened over a UI element. This feels like something that may have a built in solution, so I thought I'd ask here first. If there is no built-in solution, what approach do you suggest? I suspect modifying the Selector class would be my best bet?