protected override void OnInit(object userData) { base.OnInit(userData); m_Data = (HotfixEntityData)userData; HotfixEntityName = m_Data.HotfixEntityName; string hotfixEntityFullName = Utility.Text.Format("{0}.{1}", "Trinity.Hotfix", HotfixEntityName); //获取热更新层的实例 IType type = GameEntry.ILRuntime.AppDomain.LoadedTypes[hotfixEntityFullName]; object hotfixInstance = ((ILType)type).Instantiate(); //获取热更新层的方法并缓存 m_OnShow = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnShow", 1); m_OnHide = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnHide", 1); m_OnAttached = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnAttached", 3); m_OnDetached = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnDetached", 2); m_OnAttachTo = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnAttachTo", 3); m_OnDetachFrom = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnDetachFrom", 2); m_OnUpdate = new ILInstanceMethod(hotfixInstance, hotfixEntityFullName, "OnUpdate", 2); //调用热更新层的OnInit GameEntry.ILRuntime.AppDomain.Invoke(hotfixEntityFullName, "OnInit", hotfixInstance, this, m_Data.UserData); }
/// <summary> /// 开始执行热更新层代码 /// </summary> public void HotfixStart() { string typeFullName = "Trinity.Hotfix.HotfixEntry"; IType type = AppDomain.LoadedTypes[typeFullName]; object hotfixInstance = ((ILType)type).Instantiate(); AppDomain.Invoke(typeFullName, "Start", hotfixInstance, null); m_Update = new ILInstanceMethod(hotfixInstance, typeFullName, "Update", 2); m_ShutDown = new ILInstanceMethod(hotfixInstance, typeFullName, "ShutDown", 0); }
protected override void OnInit(object userData) { base.OnInit(userData); string hotfixUGuiFormFullName = Utility.Text.Format("{0}.{1}", "Trinity.Hotfix", m_HotfixUGuiFormName); Debug.Log(hotfixUGuiFormFullName); //获取热更新层的实例 IType type = GameEntry.ILRuntime.AppDomain.LoadedTypes[hotfixUGuiFormFullName]; object hotfixInstance = ((ILType)type).Instantiate(); //获取热更新层的方法并缓存 m_OnOpen = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnOpen", 1); m_OnClose = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnClose", 1); m_OnPause = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnPause", 0); m_OnResume = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnResume", 0); m_OnCover = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnCover", 0); m_OnReveal = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnReveal", 0); m_OnRefocus = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnRefocus", 1); m_OnUpdate = type.GetMethod("OnUpdate", 2); m_OnDepthChanged = type.GetMethod("OnDepthChanged", 2); //调用热更新层的OnInit GameEntry.ILRuntime.AppDomain.Invoke(hotfixUGuiFormFullName, "OnInit", hotfixInstance, this, userData); }