Subscribing to Events from other plugins and scripts

FlowCanvas Forums Support Subscribing to Events from other plugins and scripts

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #363
    kevynm
    Participant

    I’m using the Touchscript plugin and I want to subscribe to its TapGesture class Tapped Event. How do I do that? Or How do I subscribe to Events in general and just listen to them through my custom event node. Also, is it easier to do this in NodeCanvas? If so, How?

    Thanks!

    #364
    Gavalakis
    Keymaster

    Hello,

    The included “Code Event” node is only able to subscribe to events of type System.Action or System.Action(T). this is the case in NodeCanvas as well.
    If you have created a custom event node though, here is an example of how:

    Is this what you mean or something different?
    Thanks

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

    #366
    kevynm
    Participant

    Because Tapped Gesture is a component attached to the same gameobject. So, I can reference it inside my custom event node and subcribe to it?

    #367
    Gavalakis
    Keymaster

    Hello,

    Sorry. I though the TapGesture is a static class. You can do the same for components by some small alterations to the code above. Here it is:

    Notice that here, we instead derive from the generic class of EventNode, with an type argument of the type we need.
    ‘target.value’ gives you the actual component which is always the same type as the generic argument.
    As with all the other event nodes, you can either leave the field in the node inspector empty to get the component automaticaly from the FlowScriptController gameobject, or you can assign a reference manualy.

    Let me know if this works for you.

    Thanks

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

    #370
    kevynm
    Participant

    Yes it works! Thank you very much!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.