public static void Init() { #if UNITY_ANDROID ResLoad.Set(new AndroidResLoad()); #elif UNITY_EDITOR ResLoad.Set(new EditorResLoad()); #endif //初始化热更模块 InitHotModule(); #if COM_DEBUG //开启调试端口 appdomain.DebugService.StartDebugService(56000); #endif }
static public void InitHotModule() { if (null != appdomain) { return; } appdomain = new AppDomain(); //跨域继承注册 appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //获取全部绑定类型 { var clrType = System.Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); if (null != clrType) { clrType.GetMethod("Initialize").Invoke(null, new object[] { appdomain }); } } #region 加载DLL try { //using (var fs = ResLoad.GetStream("DyncDll.dll")) using (var fs = ResLoad.GetStream("Hotfix/Hotfix.dll")) { #if USE_PDB using (var p = ResLoad.GetStream("DyncDll.pdb")) { appdomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider()); } #else appdomain.LoadAssembly(fs); #endif } } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); } #endregion RegDelegate(appdomain); Help.Init(); }