/// <summary> /// 界面初始化 /// </summary> /// <param name="userData">用户数据</param> protected override void OnInit(object userData) { base.OnInit(userData); string hotfixUGuiFormFullName = this.gameObject.name; if (hotfixUGuiFormFullName.Contains("(Clone)")) { hotfixUGuiFormFullName = hotfixUGuiFormFullName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0]; } hotfixUGuiFormFullName = TextUtil.Format("Hotfix.{0}View", 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 = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnUpdate", 2); m_OnDepthChanged = new ILInstanceMethod(hotfixInstance, hotfixUGuiFormFullName, "OnDepthChanged", 2); //调用热更新层的OnInit GameEntry.ILRuntime.AppDomain.Invoke(hotfixUGuiFormFullName, "OnInit", hotfixInstance, this, userData); }
protected override void OnAwake() { base.OnAwake(); m_LoadAssetCallbacks = new LoadAssetCallbacks(OnLoadHotfixDLLSuccess, OnLoadHotfixDLLFailure); m_DLLLoaded = false; m_PDBLoaded = false; m_Update = null; m_ShutDown = null; AppDomain = null; assBytes = null; pdbBytes = null; dllStream = null; pdbStream = null; }
public override void Shutdown() { base.Shutdown(); m_ShutDown?.Invoke(); m_LoadAssetCallbacks = null; m_DLLLoaded = false; m_PDBLoaded = false; m_Update = null; m_ShutDown = null; AppDomain = null; assBytes = null; pdbBytes = null; dllStream = null; pdbStream = null; }
private void RefreshILStatus() { if (!m_DLLLoaded || !m_PDBLoaded) { return; } #if !ILRuntime Log.Info($"当前使用的是ILRuntime模式"); ILHelper.InitILRuntime(AppDomain); this.dllStream = new MemoryStream(assBytes); this.pdbStream = new MemoryStream(pdbBytes); this.AppDomain.LoadAssembly(this.dllStream, this.pdbStream, new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider()); string typeFullName = "Hotfix.HotfixEntry"; IType type = AppDomain.LoadedTypes[typeFullName]; 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); if (ILRuntimeReady != null) { ILRuntimeReady(); } #else Log.Info($"当前使用的是Mono模式"); this.assembly = Assembly.Load(assBytes, pdbBytes); Type hotfixInit = this.assembly.GetType("ETHotfix.Init"); this.start = new MonoStaticMethod(hotfixInit, "Start"); this.hotfixTypes = this.assembly.GetTypes().ToList(); if (ILRuntimeReady != null) { ILRuntimeReady(); } #endif }
protected override void OnInit(object userData) { base.OnInit(userData); m_Data = (HotfixEntityData)userData; m_HotfixEntityFullName = m_Data.HotfixEntityName; Debug.Log(m_HotfixEntityFullName); //获取热更新层的实例 IType type = GameEntry.ILRuntime.AppDomain.LoadedTypes[m_HotfixEntityFullName]; object hotfixInstance = ((ILType)type).Instantiate(); //获取热更新层的方法并缓存 m_OnShow = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnShow", 1); m_OnHide = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnHide", 1); m_OnAttached = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnAttached", 3); m_OnDetached = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnDetached", 2); m_OnAttachTo = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnAttachTo", 3); m_OnDetachFrom = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnDetachFrom", 2); m_OnUpdate = new ILInstanceMethod(hotfixInstance, m_HotfixEntityFullName, "OnUpdate", 2); //调用热更新层的OnInit GameEntry.ILRuntime.AppDomain.Invoke(m_HotfixEntityFullName, "OnInit", hotfixInstance, this, m_Data.UserData); }