OnTouchStarted not called on my custom user widget

Hi, I create two user widgets, one for the main UI of game, and the other for one button on the UI. I set up the OnTouchStarted/OnTouchMoved/OnTouchEnded events in the second user widget to enable touch callbacks. However, OnTouchStarted does not fire when I use mouse to click on it but the other two events work as expected.

Each user widget has a canvas, and I use overlays to instantiate and encapsulate the second user widgets.

The second user widget simply contains a button and some icons and images. Any event of the button is not set, and only the user widget’s own OnTouchStarted/OnTouchMoved/OnTouchEnded events are overriden.

image
image

I happended to find the solution myself. All you need to do is to properly set the Behavior-Visibility value in your user widget. In my case, I just set it to Visible for the root widget and Not Hit-Testable (Self) for specific children widgets.

image

Hope this helps other people who encounter this issue.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.