static void GenerateCLRBindingByAnalysis() { GenerateCLRBinding(); //用新的分析热更dll调用引用来生成绑定代码 ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain(); using (FileStream fs = new FileStream("Assets/Resources/Hotfix.dll.bytes", FileMode.Open, FileAccess.Read)) { domain.LoadAssembly(fs); //Crossbind Adapter is needed to generate the correct binding code ILRegister.InitILRuntime(domain); ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, "Assets/Scripts/ILBinding"); AssetDatabase.Refresh(); } }
static void GenerateCLRBindingByAnalysis() { //用新的分析热更dll调用引用来生成绑定代码 ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain(); using (FileStream fs = new FileStream(HotfixBuild.DllFullPath, FileMode.Open, FileAccess.Read)) { domain.LoadAssembly(fs); //Crossbind Adapter is needed to generate the correct binding code ILRegister.InitILRuntime(domain); CustomExportDefine customExportDefine = new CustomExportDefine(); ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, "Assets/Scripts/ILBinding/Binder", customExportDefine.valueTypeBinders, customExportDefine.delegateTypes, "UnityEngine_Debug_Binding" ); AssetDatabase.Refresh(); } }
public void Load(byte[] assBytes, byte[] pdbBytes) { Domain = new ILRuntime.Runtime.Enviorment.AppDomain(); dllStream = new MemoryStream(assBytes); if (pdbBytes != null) { pdbStream = new MemoryStream(pdbBytes); Domain.LoadAssembly(dllStream, pdbStream, new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider()); } else { Domain.LoadAssembly(dllStream); } #if ENABLE_PROFILER && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IOS) //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler Domain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif ILRegister.InitILRuntime(Domain); #if DEBUG Domain.DebugService.StartDebugService(56000); #endif Debug.Log($"当前使用的是ILRuntime模式"); }