You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there, I'm looking to replace UnityEvents in my project with ExtEvents but there doesn't seem to be an ExtEvent<T1, T2, T3, T4> available to replace UnityEvent<T0, T1, T2, T3> which I'm currently using.
I imagine it would look like this (just a modification of ExtEvent<T1, T2, T3>), let me know if you'd like a PR:
namespaceExtEvents{usingSystem;usingSystem.Runtime.CompilerServices;usingJetBrains.Annotations;[Serializable]publicclassExtEvent<T1,T2,T3,T4>:BaseExtEvent{privatereadonlyunsafevoid*[]_arguments=newvoid*[4];privateType[]_eventParamTypes;protectedoverrideType[]EventParamTypes=>_eventParamTypes??=newType[]{typeof(T1),typeof(T2),typeof(T3),typeof(T4)};/// <summary>/// The dynamic listeners list that you can add your listener to./// </summary>[PublicAPI]publiceventAction<T1,T2,T3,T4>DynamicListeners;internaloverrideDelegate_dynamicListeners=>DynamicListeners;/// <summary>/// Invokes all listeners of the event./// </summary>[PublicAPI]publicvoidInvoke(T1arg1,T2arg2,T3arg3,T4arg4){
unsafe
{_arguments[0]=Unsafe.AsPointer(refarg1);_arguments[1]=Unsafe.AsPointer(refarg2);_arguments[2]=Unsafe.AsPointer(refarg3);_arguments[3]=Unsafe.AsPointer(refarg4);// ReSharper disable once ForCanBeConvertedToForeachfor(intindex=0;index<_persistentListeners.Length;index++){_persistentListeners[index].Invoke(_arguments);}}DynamicListeners?.Invoke(arg1,arg2,arg3,arg4);}publicstaticExtEvent<T1,T2,T3,T4>operator+(ExtEvent<T1,T2,T3,T4>extEvent,Action<T1,T2,T3,T4>listener){if(extEvent==null)returnnull;extEvent.DynamicListeners+=listener;returnextEvent;}publicstaticExtEvent<T1,T2,T3,T4>operator-(ExtEvent<T1,T2,T3,T4>extEvent,Action<T1,T2,T3,T4>listener){if(extEvent==null)returnnull;extEvent.DynamicListeners-=listener;returnextEvent;}}}
The text was updated successfully, but these errors were encountered:
Hey there, I'm looking to replace UnityEvents in my project with ExtEvents but there doesn't seem to be an
ExtEvent<T1, T2, T3, T4>
available to replaceUnityEvent<T0, T1, T2, T3>
which I'm currently using.I imagine it would look like this (just a modification of
ExtEvent<T1, T2, T3>
), let me know if you'd like a PR:The text was updated successfully, but these errors were encountered: