少年修仙传客户端基础资源
lwb
2021-01-26 f6ab248e23fb6485f4121294ff4167e8a15a47a3
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using UnityEngine;
 
public class ILBehaviour : WidgetBehavior
{
    [Tooltip("Logic工程的代码,例:命名空间.类名")]
    public string className;
    ILTypeInstance obj;
 
    IMethod awake, start, onEnable, onDisable, update, fixedUpdate, lateUpdate, onDestroy;
 
    AppDomain appDomain {
        get { return ILRuntimeUtility.Instance.appDomain; }
    }
 
    public object ILInstance {
        get { return obj; }
    }
 
    private void Init()
    {
        InitWidgts();
        obj = appDomain.Instantiate(className, new object[] { this });
        var baseType = appDomain.LoadedTypes["LogicProject.BaseILBehaviour"];
        if (obj == null)
        {
            DebugEx.LogErrorFormat("ILBehaviour �ȸ����벻���ڣ�{0}", className);
            return;
        }
        var type = obj.Type;
        awake = type.GetMethod("Awake");
        start = type.GetMethod("Start");
        onEnable = type.GetMethod("OnEnable");
        onDisable = type.GetMethod("OnDisable");
        update = type.GetMethod("Update");
        fixedUpdate = type.GetMethod("FixedUpdate");
        lateUpdate = type.GetMethod("LateUpdate");
        onDestroy = baseType.GetMethod("OnDestroy",0);
    }
 
    private void Awake()
    {
        Init();
        if (awake != null)
            appDomain.Invoke(awake, obj);
    }
 
    private void Start()
    {
        if (start != null)
            appDomain.Invoke(start, obj);
    }
 
    private void OnEnable()
    {
        if (onEnable != null)
            appDomain.Invoke(onEnable, obj);
    }
 
    private void OnDisable()
    {
        if (onDisable != null)
            appDomain.Invoke(onDisable, obj);
    }
 
    private void Update()
    {
        if (update != null)
            appDomain.Invoke(update, obj);
    }
 
    private void FixedUpdate()
    {
        if (fixedUpdate != null)
            appDomain.Invoke(fixedUpdate, obj);
    }
 
    private void LateUpdate()
    {
        if (lateUpdate != null)
            appDomain.Invoke(lateUpdate, obj);
    }
 
    private void OnDestroy()
    {
        if (onDestroy != null)
            appDomain.Invoke(onDestroy, obj);
        awake = null;
        start = null;
        onEnable = null;
        onDisable = null;
        update = null;
        fixedUpdate = null;
        lateUpdate = null;
        onDestroy = null;
        obj = null;
    }
 
}