Let say I have an action like this:
public Action OnSomeAction;
I would like to be able to subscribe to this action from outside of the class, but not be able to invoke it:
OnSomeAction.Invoke();
Is there a way to do this without making the action private and creating methods for subscribing and unsubscribing like this:
private Action _someAction;
public void Subscribe(Action listener)
{
_someAction += listener;
}
public void Unsubscribe(Action listener)
{
_someAction -= listener;
}
private void Invoke()
{
_someAction.Invoke();
}