Button click issue

this below Play Now button is sometimes clickable but sometimes it does not trigger for even 5 to 6 clicks .it happens frequently. Hopw can i resolve this.
Screenshot is shown below


Hi @gouthamamin,

How is your code to capture the button click looks like?

I don’t see anything wrong with your setup, unless on runtime the button element is hidden behind other elements, it should click.

Can you try listening to button click instead and see if that fixes it?

this.button.button.on('click', this.onButtonDown, this);

No it didnt work

Try sharing if possible a sample project that reproduces your issue.

is it a issue related to layers ??

No, I don’t think so, all elements by default are rendering in the UI layer.

Normally, the 2D screen has a different icon than that. Could you show us the attributes of the 2D screen or share a link to the project?

1 Like


Hi @gouthamamin,

You screenshot explains things. In order for the button and element click events to work, you will need the elements to be children of a 2D or 3D Screen component. Those look like this:

image

Take a look at these pages for more information:

https://developer.playcanvas.com/en/user-manual/user-interface/screens/
https://developer.playcanvas.com/en/user-manual/user-interface/elements/

I hope this is helpful.

1 Like

I got it, that was due to z position of the button. now it works fine