Forum rules - please read before posting.

Onclick() functionality like in the normal unity UI

Hey,
In my project I have a button with a monobehavior with the function Onclick. I want to run the Onclick function when clicking the button. I'm using unity UI for this within the Menu manager. There are many similar buttons, but I want that only the Onclick function of this button will run.

Is there a trivial way of doing it like the Onclick event with unity button (which doesn't work here)?
I tried to use a ActionList with a SendMessage, but it will trigger all buttons.
I tried to use the custom script option, but I need to check everytime which menu and element I'm pressing within the function. It's ok but I have a lot of them and it looks like not the way to go.

what is the proper way of doing this?
Thanks!

Comments

  • If the script's function is public, you can assign it to the Unity UI's Button component directly within the On Click event Inspector.

    Since you're handling the click behaviour yourself, you don't need to link it to AC's Menu Manager - even if the rest of the Menu is.

  • Oh it works perfectly. I had a bug on my end that made me think that wouldn't work. Thanks Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.