From a802cddeed5042fe421403c601fb7f30953bb041 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Thu, 26 May 2022 20:23:17 +0800 Subject: [PATCH] Update LoadDll.cs --- .../Runtime/HotUpdate/Runtime/LoadDll.cs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Assets/TEngine/Runtime/HotUpdate/Runtime/LoadDll.cs b/Assets/TEngine/Runtime/HotUpdate/Runtime/LoadDll.cs index 11685bed..5a1513e2 100644 --- a/Assets/TEngine/Runtime/HotUpdate/Runtime/LoadDll.cs +++ b/Assets/TEngine/Runtime/HotUpdate/Runtime/LoadDll.cs @@ -19,14 +19,14 @@ public class LoadDll : MonoBehaviour private void LoadGameDll() { - -#if UNITY_EDITOR - TextAsset dllBytes2 = TResources.Load("DLL/GameLogic.dll.bytes"); +#if !UNITY_EDITOR + TextAsset dllBytes2 = TResources.Load("DLL/TEngineHotUpdate.dll.bytes"); + //生产模式从bytes加载 gameLogic = System.Reflection.Assembly.Load(dllBytes2.bytes); #else - gameLogic = AppDomain.CurrentDomain.GetAssemblies().First(assembly => assembly.GetName().Name == "GameLogic"); + //编辑器模式从dll反射加载 + gameLogic = AppDomain.CurrentDomain.GetAssemblies().First(assembly => assembly.GetName().Name == "TEngineHotUpdate"); #endif - } private void RunMain() @@ -37,20 +37,29 @@ public class LoadDll : MonoBehaviour return; } - Type appType = gameLogic.GetType("GameMain"); - MethodInfo mainMethod = appType.GetMethod("RunMain"); - mainMethod?.Invoke(null, null); + AddMyComponent("TEngineCore.TEngineDemo", this.gameObject); - updateMethod = appType.GetMethod("Update"); - var updateDel = System.Delegate.CreateDelegate(typeof(Action), null, updateMethod); + //Type appType = gameLogic.GetType("TEngineCore.TEngine"); + //MethodInfo mainMethod = appType.GetMethod("InitLibImp"); + //mainMethod?.Invoke(null, null); + + //updateMethod = appType.GetMethod("Update"); + //var updateDel = System.Delegate.CreateDelegate(typeof(Action), null, updateMethod); } + void AddMyComponent(string className, GameObject obj) + { + Type type = gameLogic.GetType(className); + obj.AddComponent(type); + } + + void Update() { - if (gameLogic == null) - { - return; - } - updateMethod?.Invoke(Time.deltaTime,null); + //if (gameLogic == null) + //{ + // return; + //} + //updateMethod?.Invoke(Time.deltaTime,null); } -} +} \ No newline at end of file