using UnityEngine;
using UnityEngine.Events;

public class Publisher : MonoBehaviour
{
    public UnityEvent eventWithNoArguments;
    public UnityEvent<int> eventWithIntArgument;

    void Update()
    {
        // When any key is pressed, invoke our events
        if (Input.anyKeyDown)
        {
            // We use the (?) to check to see if our event has subscribers.
            // If there are no subscribers we do not invoke the event. Otherwise we do invoke the event.
            eventWithNoArguments?.Invoke();
            eventWithIntArgument?.Invoke(42);
        }
    }
}
