diff options
Diffstat (limited to 'ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs')
-rw-r--r-- | ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs new file mode 100644 index 0000000..916d553 --- /dev/null +++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; + +public abstract class SerializableEventBase : SerializableCallbackBase { + public InvokableEventBase invokable; + + public override void ClearCache() { + base.ClearCache(); + invokable = null; + } + + protected InvokableEventBase GetPersistentMethod() { + Type[] types = new Type[ArgTypes.Length]; + Array.Copy(ArgTypes, types, ArgTypes.Length); + + Type genericType = null; + switch (types.Length) { + case 0: + genericType = typeof(InvokableEvent); + break; + case 1: + genericType = typeof(InvokableEvent<>).MakeGenericType(types); + break; + case 2: + genericType = typeof(InvokableEvent<,>).MakeGenericType(types); + break; + case 3: + genericType = typeof(InvokableEvent<, ,>).MakeGenericType(types); + break; + case 4: + genericType = typeof(InvokableEvent<, , ,>).MakeGenericType(types); + break; + default: + throw new ArgumentException(types.Length + "args"); + } + return Activator.CreateInstance(genericType, new object[] { target, methodName }) as InvokableEventBase; + } +}
\ No newline at end of file |