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()
|
private void LoadGameDll()
|
||||||
{
|
{
|
||||||
|
#if !UNITY_EDITOR
|
||||||
#if UNITY_EDITOR
|
TextAsset dllBytes2 = TResources.Load<TextAsset>("DLL/TEngineHotUpdate.dll.bytes");
|
||||||
TextAsset dllBytes2 = TResources.Load<TextAsset>("DLL/GameLogic.dll.bytes");
|
//生产模式从bytes加载
|
||||||
gameLogic = System.Reflection.Assembly.Load(dllBytes2.bytes);
|
gameLogic = System.Reflection.Assembly.Load(dllBytes2.bytes);
|
||||||
#else
|
#else
|
||||||
gameLogic = AppDomain.CurrentDomain.GetAssemblies().First(assembly => assembly.GetName().Name == "GameLogic");
|
//编辑器模式从dll反射加载
|
||||||
|
gameLogic = AppDomain.CurrentDomain.GetAssemblies().First(assembly => assembly.GetName().Name == "TEngineHotUpdate");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunMain()
|
private void RunMain()
|
||||||
@@ -37,20 +37,29 @@ public class LoadDll : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type appType = gameLogic.GetType("GameMain");
|
AddMyComponent("TEngineCore.TEngineDemo", this.gameObject);
|
||||||
MethodInfo mainMethod = appType.GetMethod("RunMain");
|
|
||||||
mainMethod?.Invoke(null, null);
|
|
||||||
|
|
||||||
updateMethod = appType.GetMethod("Update");
|
//Type appType = gameLogic.GetType("TEngineCore.TEngine");
|
||||||
var updateDel = System.Delegate.CreateDelegate(typeof(Action<float>), null, updateMethod);
|
//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()
|
void Update()
|
||||||
{
|
{
|
||||||
if (gameLogic == null)
|
//if (gameLogic == null)
|
||||||
{
|
//{
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
updateMethod?.Invoke(Time.deltaTime,null);
|
//updateMethod?.Invoke(Time.deltaTime,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user