From 5ad34b959b1f5a50be6675ab1004008f6a37279b Mon Sep 17 00:00:00 2001
From: lwb <q3213421wrwqr>
Date: 星期五, 19 二月 2021 18:09:53 +0800
Subject: [PATCH] 9527 ilruntime
---
Assets/ILRuntime/Src/ILLauncherProxy.cs | 62 +++++++++++++++++++++++++------
1 files changed, 50 insertions(+), 12 deletions(-)
diff --git a/Assets/ILRuntime/Src/ILRuntimeLoader.cs b/Assets/ILRuntime/Src/ILLauncherProxy.cs
similarity index 84%
rename from Assets/ILRuntime/Src/ILRuntimeLoader.cs
rename to Assets/ILRuntime/Src/ILLauncherProxy.cs
index a6a5c42..647a3f9 100644
--- a/Assets/ILRuntime/Src/ILRuntimeLoader.cs
+++ b/Assets/ILRuntime/Src/ILLauncherProxy.cs
@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.IO;
using ILCrossBinding;
+using ILRuntime.CLR.Method;
using ILRuntime.Mono.Cecil.Pdb;
+using ILRuntime.Runtime.Intepreter;
using Snxxz.UI;
using UnityEngine;
-public class ILRuntimeLoader : SingletonMonobehaviour<ILRuntimeLoader>
+public class ILLauncherProxy : SingletonMonobehaviour<ILLauncherProxy>
{
FileStream dllFS, pdbFS;
@@ -16,14 +18,19 @@
{
get
{
- if (_appdomain == null)
- DebugEx.Log("AppDomain 璋冪敤鏃朵负绌猴紒");
return _appdomain;
}
}
+ public bool started;
+
+ ILTypeInstance launcherInstance;
+
+ IMethod update, onDestroy;
+
public void Init()
{
+ started = false;
LoadILRuntime();
//鐢变簬Unity鐨凱rofiler鎺ュ彛鍙厑璁稿湪涓荤嚎绋嬩娇鐢紝涓轰簡閬垮厤鍑哄紓甯革紝闇�瑕佸憡璇塈LRuntime涓荤嚎绋嬬殑绾跨▼ID鎵嶈兘姝g‘灏嗗嚱鏁拌繍琛岃�楁椂鎶ュ憡缁橮rofiler
#if UNITY_EDITOR
@@ -143,14 +150,7 @@
appDomain.DelegateManager.RegisterMethodDelegate<Window>();
appDomain.DelegateManager.RegisterMethodDelegate<TimeMgr.SyntonyType>();
appDomain.DelegateManager.RegisterMethodDelegate<DateTime>();
-
- appDomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction>((action) =>
- {
- return new UnityEngine.Events.UnityAction(() =>
- {
- ((System.Action)action)();
- });
- });
+ appDomain.DelegateManager.RegisterMethodDelegate<System.Object>();
//鏈夎繑鍥炲��
appDomain.DelegateManager.RegisterFunctionDelegate<int>();
@@ -160,6 +160,29 @@
appDomain.DelegateManager.RegisterFunctionDelegate<float>();
appDomain.DelegateManager.RegisterFunctionDelegate<double>();
appDomain.DelegateManager.RegisterFunctionDelegate<int, bool>();
+ appDomain.DelegateManager.RegisterFunctionDelegate<System.Int32, System.Int32, System.Int32>();
+
+ appDomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction>((action) =>
+ {
+ return new UnityEngine.Events.UnityAction(() =>
+ {
+ ((System.Action)action)();
+ });
+ });
+ appDomain.DelegateManager.RegisterDelegateConvertor<System.Threading.WaitCallback>((act) =>
+ {
+ return new System.Threading.WaitCallback((state) =>
+ {
+ ((Action<System.Object>)act)(state);
+ });
+ });
+ appDomain.DelegateManager.RegisterDelegateConvertor<System.Comparison<System.Int32>>((act) =>
+ {
+ return new System.Comparison<System.Int32>((x, y) =>
+ {
+ return ((Func<System.Int32, System.Int32, System.Int32>)act)(x, y);
+ });
+ });
}
public void LaunchStart()
@@ -167,12 +190,27 @@
#if UNITY_EDITOR
_appdomain.DebugService.StartDebugService(56000);
#endif
- _appdomain.Invoke("GameLogicMgr", "Init", null, null);
+ launcherInstance = appDomain.Instantiate("LogicLauncher");
+ var type = launcherInstance.Type;
+ update = type.GetMethod("Update");
+ onDestroy = type.GetMethod("OnDestroy", 0);
+
+ _appdomain.Invoke("LogicLauncher", "LaunchStart", launcherInstance, null);
+ }
+
+ private void Update()
+ {
+ if (update != null)
+ appDomain.Invoke(update, launcherInstance);
}
protected override void OnDestroy()
{
base.OnDestroy();
+
+ if (onDestroy != null)
+ appDomain.Invoke(onDestroy, launcherInstance);
+
#if UNITY_EDITOR
var type = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings");
if (type != null)
--
Gitblit v1.8.0