blob: 916d5530769dc95598a7c0d484d430c194cd8c08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
}
|