Best way to get onClick event from instantiated buttons?

NodeCanvas Forums Support Best way to get onClick event from instantiated buttons?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11396
    stephenson
    Participant

    Hi,

    I’m instantiating a list of buttons and I’m looking for a way to get an onClick event from these buttons. Since they are prefabs I can’t target them using the Button Clicked action.

    What’s the best way of doing this?

    Is there a way I can put the Buttons in an array and then listen for an onClick event from all buttons in an array?

    I’m also using Playmaker so can I get an onClick event from the button clicked to send an event to the Node Canvas graph? I see there is a Send Owner Event action in the Playmaker actions list but I can’t figure out how to use it. Playmaker tutorials and examples would be great BTW.

    Thanks for your help.

    M.

    #11408
    Gavalakis
    Keymaster

    Hello,

    The Button reference in the ButtonClicked condition, can also be used with Variables instead of only direct references. As such, you can instantiate your Button, store the instance in a temporary variable and use that variable in the ButtonClicked condition.

    ButtonInstanceVariable

    While there are some actions included to handle Lists, because each separate button onClick event is usually used to perform something different, each button registration is implemented as a different Condition.

    What actions does Playmaker have that can benefit in your case? If you let me know I could create such an action for you in NodeCanvas, so that you don’t have to perform additional operations in Playmaker just for this.

    Let me know.
    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.