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;
|
}
|
|
}
|