Hello,
I can’t wrap my head around why this won’t fire. Maybe I’m just looking at it completely wrong. But I just want an onscreen d-pad where an event is fired at pointerdown and up to control the player object like this:

The script “controller” has 2 functions doAction with a parameter and cancelAction that just logs for now, but nothing happens. What am I doing wrong?
Thanks!
“Interactable” has to be checked for the button to fire events.
1 Like
I tried different things, but I get the same result with the interactable checked on. Isn’t the interactable checkbox just to fire the on click event on the button script itself?
Ah yes, you are right about that. I never tested it out until now.
I opened a new project, right clicked into the hierarchy and created a new UI button. That autogenerated the Canvas and EventSystem objects. I added the event triggers to the button, and linked them to a test script with two public methods that print out. They are both printing properly with/without interactable checked.
As far as I can see from your screenshots, everything looks fine. Make sure your Canvas has a Graphics Raycaster, and that you’re not clicking something invisible that overlaps the button.
If you set your inspector to debug mode using the top right “three lines” menu, you can see which object is being selected by your clicks:
1 Like
apparently[quote=“LiterallyJeff, post:4, topic: 767600, username:LiterallyJeff”]
Ah yes, you are right about that. I never tested it out until now.
I opened a new project, right clicked into the hierarchy and created a new UI button. That autogenerated the Canvas and EventSystem objects. I added the event triggers to the button, and linked them to a test script with two public methods that print out. They are both printing properly with/without interactable checked.
As far as I can see from your screenshots, everything looks fine. Make sure your Canvas has a Graphics Raycaster, and that you’re not clicking something invisible that overlaps the button.
If you set your inspector to debug mode using the top right “three lines” menu, you can see which object is being selected by your clicks:
[/quote]
Thanks for all the tips!
The problem actually situated right outside of my screenshot. I disabled the image component on the buttons, so I guess they were not raycasting then which means it won’t fire? I enabled them and just turned down the alpha value. Stupid error I made, but I understand how stuff works in Unity a bit more now.
Thanks for the help anyway!
2 Likes