mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update LoadDll.cs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user