I have a delegate wrapper called SerializedAction
[Serializable]
public class SerializedAction
{
private Action action;
public void Add (Action handler) {...}
public void Remove (Action handler) {...}
public void Invoke () { Get().Invoke(); }
public static SerializedAction operator +(SerializedAction action, Action handler) {...}
public static SerializedAction operator -(SerializedAction action, Action handler) {...}
private RebuildInvocationList() {...}
private Action Get() {...}
...
}
I have managed to overload the +/- operators so I don't have to explicitly call Add
and Remove
- But whenever I want to invoke, I have to call Invoke
- I was wondering if there was a way to invoke it like a normal delegate, i.e.
var meAction = new SerializedAction();
meAction += handler;
meAction(); // instead of meAction.Invoke()?
Is this possible somehow?
Thanks.