/// <summary> /// Registers a C# listener for an event on the target object. This is the scripting /// equivalent to the Defined Event unit. Notice the IDisposable return value, which allows you /// to end the subscription for the event (via calling the .Dispose() method). /// </summary> /// <typeparam name="T">The type to listen for.</typeparam> /// <param name="target">The game object to listen on to receive the event.</param> /// <param name="onEvent">The action or method to call when the event occurs</param> /// <returns>A disposable that, when .Dispose is called, will unsubscribe from the /// event, essentially cancelling the call to RegisterListener.</returns> public static IDisposable RegisterListener <T>(GameObject target, Action <T> onEvent) { return(DefinedEventUnit.RegisterListener <T>(target, onEvent)); }
/// <summary> /// Triggers Defined Event units listening for the passed eventData on the target gameobject. /// This is the scripting quivalent to the Trigger Defined Event unit. /// </summary> /// <param name="target">The game object that event units should listen on to receive the event.</param> /// <param name="eventData">This is a filled object of the type of event you want to trigger.</param> public static void Trigger(GameObject target, object eventData) { DefinedEventUnit.Trigger(target, eventData); }