Update LoadDll.cs

This commit is contained in:
ALEXTANG
2022-05-26 20:23:17 +08:00
parent 2f9d40b686
commit a802cddeed

View File

@@ -19,14 +19,14 @@ public class LoadDll : MonoBehaviour
private void LoadGameDll()
{
#if UNITY_EDITOR
TextAsset dllBytes2 = TResources.Load<TextAsset>("DLL/GameLogic.dll.bytes");
#if !UNITY_EDITOR
TextAsset dllBytes2 = TResources.Load<TextAsset>("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<float>), 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<float>), 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);
}
}