Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Triggering a Unity Event

Discussion in 'Visual Scripting' started by Zecrah, Nov 7, 2020.

  1. Zecrah


    Nov 1, 2016
    Hey everyone,

    I've really tried to search for this but just don't understand what I'm missing. This seems like Events 101 but I'm stuck.

    I'm migrating some of my code for a small project into Bolt. I'm trying to migrate some of the event logic. Right now, in code, I have some events. An example is below - an event that is invoked whenever a property changes:

    Code (CSharp):
    1. public static UnityEvent ue_MemberCountChanged = new UnityEvent();
    3. //.....
    5.     private static int _memberCount;
    6.     public static int MemberCount
    7.     {
    8.         get
    9.             return _memberCount;
    11.         set {
    12.             _memberCount = value;
    13.             ue_MemberCountChanged?.Invoke();
    14.         }
    15.     }
    There's a few different listeners on this event.

    How am I supposed to replicate this in Bolt? I've tried adding a 'Trigger Unity Event' unit, but for some reason I'm forced to specify the Game Object that will receive the event - which seems counter intuitive and I might as well just call functions directly.


    In an old post on the Ludiq forums, "Wes" notes this too and then Lazlo replies saying it's possible to trigger an event in the graph. I can't find out how to do this without being forced to use the above.

    I've also combed the documentation and it just seems really light on details, stating events can be created in your own custom scripts but then goes on to demonstrate calling an event on a specific machine from a button. Again, seems useless.

    How do I invoke a UnityEvent for all listeners, regardless of whether they're on this graph, another graph, or in code?
  2. Zecrah


    Nov 1, 2016
    For anyone else who gets stuck on this, it isn't possible in a vanilla configuration. I ended up coming across this Bolt Unity Events asset, which should really be part of the package from the start. But hey. :)
    homemacai likes this.