using System; using System.Collections.Generic; using System.Reflection; using ILRuntime.CLR.Method; using ILRuntime.CLR.TypeSystem; using ILRuntime.Runtime.Enviorment; using ILRuntime.Runtime.Generated; using ILRuntime.Runtime.Intepreter; using UnityEngine; namespace ETModel { public static class ILHelper { public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate>(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterFunctionDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); } } }