static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new IEqualityComparerAdaptor()); domain.RegisterCrossBindingAdaptor(new IEnumerableAdaptor()); }
public static void InitILRuntime(AppDomain appDomain) { //TODO:注册重定向方法 //TODO:适配委托 appDomain.DelegateManager.RegisterMethodDelegate <float>(); appDomain.DelegateManager.RegisterMethodDelegate <object, GameFramework.Event.GameEventArgs>(); appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, byte, ushort, MemoryStream>(); appDomain.DelegateManager.RegisterMethodDelegate <Session>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterFunctionDelegate <IMessageAdaptor.Adaptor>(); appDomain.DelegateManager.RegisterMethodDelegate <IMessageAdaptor.Adaptor>(); //TODO:注册委托 appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction>((action) => { return(new UnityAction(() => { ((Action)action)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction <float> >((action) => { return(new UnityAction <float>((a) => { ((Action <float>)action)(a); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <GameFramework.Event.GameEventArgs> >((act) => { return(new System.EventHandler <GameFramework.Event.GameEventArgs>((sender, e) => { ((Action <System.Object, GameFramework.Event.GameEventArgs>)act)(sender, e); })); }); //注册CLR绑定代码 CLRBindings.Initialize(appDomain); //TODO:注册跨域继承适配器 appDomain.RegisterCrossBindingAdaptor(new GameEventArgsAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IReferenceAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IMessageAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IDisposableAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineAdaptor()); //注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); }
void InitializeIlRuntime() { //默认委托注册仅仅支持系统自带的Action以及Function m_AppDomain.DelegateManager.RegisterMethodDelegate <bool>(); m_AppDomain.DelegateManager.RegisterFunctionDelegate <int, string>(); m_AppDomain.DelegateManager.RegisterMethodDelegate <int>(); m_AppDomain.DelegateManager.RegisterMethodDelegate <string>(); m_AppDomain.DelegateManager .RegisterMethodDelegate <System.String, UnityEngine.Object, System.Object, System.Object, System.Object>(); m_AppDomain.DelegateManager .RegisterMethodDelegate <System.String, UnityEngine.Object, System.Object, System.Object>(); //自定义委托或Unity委托注册 m_AppDomain.DelegateManager.RegisterDelegateConvertor <TestDelegateMeth>((action) => { return(new TestDelegateMeth((a) => { ((System.Action <int>)action)(a); })); }); m_AppDomain.DelegateManager.RegisterDelegateConvertor <TestDelegateFunction>((action) => { return(new TestDelegateFunction((a) => { return ((System.Func <string, string>)action)(a); })); }); m_AppDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <bool> >((action) => { return(new UnityEngine.Events.UnityAction <bool>((a) => { ((System.Action <bool>)action)(a); })); }); m_AppDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((action) => { return(new UnityEngine.Events.UnityAction(() => { ((System.Action)action)(); })); }); m_AppDomain.DelegateManager.RegisterDelegateConvertor <OnAsyncObjFinish>((action) => { return(new OnAsyncObjFinish((path, obj, param1, param2, param3) => { ((System.Action <System.String, UnityEngine.Object, System.Object, System.Object, System.Object>) action)(path, obj, param1, param2, param3); })); }); //跨域继承的注册 m_AppDomain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); //注册协程适配器 m_AppDomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //注册Mono适配器 m_AppDomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); //注册Window适配器 m_AppDomain.RegisterCrossBindingAdaptor(new WindowAdapter()); SetupCLRAddCompontent(); SetUpCLRGetCompontent(); //绑定注册 (最后执行) ILRuntime.Runtime.Generated.CLRBindings.Initialize(m_AppDomain); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new TestClassBaseAdapter()); domain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); }
public static void InitAdaptor(AppDomain appDomain) { //游戏用 appDomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); appDomain.RegisterCrossBindingAdaptor(new Adapt_IComparable()); appDomain.RegisterCrossBindingAdaptor(new Adapt_MComponent()); appDomain.RegisterCrossBindingAdaptor(new Adapt_MSystem()); }
unsafe void InitializeILRuntime() { #if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE) //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler appdomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; appdomain.DebugService.StartDebugService(56000); #endif #region 这里添加ILRuntime的注册 appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); appdomain.DelegateManager.RegisterFunctionDelegate <System.Text.RegularExpressions.Match, System.String>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appdomain.DelegateManager.RegisterFunctionDelegate <System.Boolean>(); appdomain.DelegateManager.RegisterFunctionDelegate <bool>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject, System.Action>(); appdomain.DelegateManager.RegisterDelegateConvertor <System.Text.RegularExpressions.MatchEvaluator>((act) => { return(new System.Text.RegularExpressions.MatchEvaluator((match) => ((Func <System.Text.RegularExpressions.Match, System.String>)act)(match))); }); appdomain.DelegateManager.RegisterDelegateConvertor <Action <JsonData> >((action) => { return(new Action <JsonData>((a) => { ((System.Action <JsonData>)action)(a); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(async() => { ((Action)act)(); })); }); #endregion ILRuntime.Runtime.Generated.CLRBindings.Initialize(appdomain); var arr = typeof(GameObject).GetMethods(); foreach (var i in arr) { if (i.Name == "AddComponent" && i.GetGenericArguments().Length == 1) { appdomain.RegisterCLRMethodRedirection(i, AddComponent); } } foreach (var i in arr) { if (i.Name == "GetComponent" && i.GetGenericArguments().Length == 1) { appdomain.RegisterCLRMethodRedirection(i, GetComponent); } } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new Adapt_IMessage()); domain.DelegateManager.RegisterFunctionDelegate <Adapt_IMessage.Adaptor>(); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //domain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); }
//¿çÓò¼Ì³Ð-ÊÊÅäÆ÷µÄ×¢²á public static void RegisterAdaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { //appdomain.RegisterCrossBindingAdaptor(new BaseWindowAdaptor()); //asyncµÄÊÊÅä appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); appdomain.RegisterCrossBindingAdaptor(new Adapt_IMessage()); //appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new DownloadHandlerScriptAdapter()); domain.RegisterCrossBindingAdaptor(new ProtobufAdapter()); domain.RegisterCrossBindingAdaptor(new SerializeMessageAdapter()); // domain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); }
unsafe void InitializeILRuntime() { InitDelegates(); SetupCLRRedirection(); //这里做一些ILRuntime的注册 appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); ILRuntime.Runtime.Generated.CLRBindings.Initialize(appdomain); }
unsafe void InitializeILRuntime() { InitDelegates(); SetupCLRRedirection(); //这里做一些ILRuntime的注册 appdomain.RegisterCrossBindingAdaptor(new IDisposableAdapter()); appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); ILRuntime.Runtime.Generated.CLRBindings.Initialize(appdomain); }
static void SetupCrossBinding() { app.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); app.RegisterCrossBindingAdaptor(new IDisposableAdapter()); app.RegisterCrossBindingAdaptor(new IEnumerableAdapter <byte>()); app.RegisterCrossBindingAdaptor(new IEnumerableAdapter <int>()); app.RegisterCrossBindingAdaptor(new IEnumerableAdapter <ILTypeInstance>()); app.RegisterCrossBindingAdaptor(new IEnumeratorAdapter <ILTypeInstance>()); app.RegisterCrossBindingAdaptor(new IEnumeratorAdapter <System.Object>()); app.RegisterCrossBindingAdaptor(new IOExceptionAdapter()); app.RegisterCrossBindingAdaptor(new IComparableAdapter <ILTypeInstance>()); app.RegisterCrossBindingAdaptor(new IPBChannelAdapter()); }
public static void RegisterCrossBindingAdaptor(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这几条是手写的 domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //以下是自动生成的 domain.RegisterCrossBindingAdaptor(new ScriptableObjectAdapter()); domain.RegisterCrossBindingAdaptor(new ExceptionAdapter()); domain.RegisterCrossBindingAdaptor(new IEnumerableAdapter()); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 //domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); //domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //domain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); //Debug.LogErrorFormat("RegisterCrossBindingAdaptor MessageAdapter"); //domain.RegisterCrossBindingAdaptor(new MessageAdapter()); //domain.RegisterCrossBindingAdaptor(new IOExceptionAdapter()); //domain.RegisterCrossBindingAdaptor(new EqualityComparerAdapter()); //domain.RegisterCrossBindingAdaptor(new EqualityComparerSingleAdapter()); //domain.RegisterCrossBindingAdaptor(new EqualityComparerNullableDoubleAdapter()); //domain.RegisterCrossBindingAdaptor(new EqualityComparerNullableSingleAdapter()); //domain.RegisterCrossBindingAdaptor(new ListAdapter_Protobuf()); domain.RegisterCrossBindingAdaptor(new ListStringAdapter()); domain.RegisterCrossBindingAdaptor(new ListInt32Adapter()); domain.RegisterCrossBindingAdaptor(new Adapter_Protobuf()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((action) => { return(new UnityEngine.Events.UnityAction(() => { ((System.Action)action)(); })); }); domain.DelegateManager.RegisterDelegateConvertor <System.Action>((action) => { return(new System.Action(() => { ((System.Action)action)(); })); }); domain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <System.Net.Sockets.SocketAsyncEventArgs> >((act) => { return(new System.EventHandler <System.Net.Sockets.SocketAsyncEventArgs>((sender, e) => { ((System.Action <System.Object, System.Net.Sockets.SocketAsyncEventArgs>)act)(sender, e); })); }); domain.DelegateManager.RegisterMethodDelegate <System.Object, System.Net.Sockets.SocketAsyncEventArgs>(); domain.DelegateManager.RegisterFunctionDelegate <System.Reflection.MethodInfo>(); }
private void OnHotFixLoaded() { TestClassBase obj; try { obj = appdomain.Instantiate <TestClassBase>("HotFix_Project.MyTestInheritance"); } catch (Exception ex) { Debug.Log(ex); } Debug.Log("Oops, 报错了,因为跨域继承必须要注册适配器。 如果是热更DLL里面继承热更里面的类型,不需要任何注册。"); Debug.Log("所以现在我们来注册适配器"); appdomain.RegisterCrossBindingAdaptor(new MyInheritanceAdapter()); Debug.Log("现在再来尝试创建一个实例"); obj = appdomain.Instantiate <TestClassBase>("HotFix_Project.MyTestInheritance"); Debug.Log("现在来调用成员方法"); obj.TestAbstract(456); obj.TestVirtual("Hello World"); //Debug.Log(obj.Value); Debug.Log("现在换个方式创建实例"); obj = appdomain.Invoke("HotFix_Project.MyTestInheritance", "NewObject", null, null) as TestClassBase; obj.TestAbstract(678); obj.TestVirtual("second"); }
public static void RegisterCrossBindingAdaptor(AppDomain appdomain) { foreach (var adaptor in _adaptors) { appdomain.RegisterCrossBindingAdaptor((CrossBindingAdaptor)ReflectionHelper.CreateInstance(adaptor)); } }
public void Init() { using (System.IO.MemoryStream fs = new MemoryStream(HotFixDll.bytes)) { m_AssemblyILR.LoadAssembly(fs); } m_AssemblyILR.AllowUnboundCLRMethod = true; ILRuntime.Runtime.Enviorment.AppDomain.ShowDebugInfo = false; //注册跨域类 m_AssemblyILR.RegisterCrossBindingAdaptor(new IGameHotFixInterfaceAdapter()); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <System.Int32>(); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <System.Boolean>(); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance>(); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <System.Int32, System.Int32>(); m_AssemblyILR.DelegateManager.RegisterMethodDelegate <System.Object>(); LCLFunctionDelegate.Reg(m_AssemblyILR); ILRuntime.Runtime.Generated.CLRBindings.Initialize(m_AssemblyILR); string HotFixLoop = "LCL.HotFixLoop"; m_HotFixDll = m_AssemblyILR.Instantiate <IGameHotFixInterface>(HotFixLoop); m_HotFixDll.Start(); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { #if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE) //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler appdomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif //这里做一些ILRuntime的注册,这里我们注册值类型Binder,注释和解注下面的代码来对比性能差别 appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); InitDelegates(appdomain); SetupCLRRedirection(appdomain); // 注册适配器(需要在适配器添加 ILAdapterAttribute 标签) 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); } CLRBindings.Initialize(appdomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new ProcedureBaseAdaptor()); // domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //domain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 //domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); //domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new IGameHotFixInterfaceAdapter()); }
unsafe void InitializeILRuntime() { //这里做一些ILRuntime的注册 appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); appdomain.DelegateManager.RegisterMethodDelegate <string, string, LogType>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Application.LogCallback>((act) => { return(new UnityEngine.Application.LogCallback((condition, stackTrace, type) => { ((Action <System.String, System.String, UnityEngine.LogType>)act)(condition, stackTrace, type); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <float> >((action) => { return(new UnityEngine.Events.UnityAction <float>((a) => { ((System.Action <float>)action)(a); })); }); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); //注册绑定的导出类 //CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(ILRegister).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); }
unsafe void InitializeILRuntime() { //重定向log var mi = typeof(Debug).GetMethod("Log", new System.Type[] { typeof(object) }); appdomain.RegisterCLRMethodRedirection(mi, DebugLogRedirection.Log_11); appdomain.RegisterCrossBindingAdaptor(new AS3Proto.MessageAdapter()); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterFunctionDelegate <KeyValuePair <String, Int32>, Int32>(); appdomain.DelegateManager.RegisterFunctionDelegate <KeyValuePair <String, Int32>, String>(); appdomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Int32>(); appdomain.DelegateManager.RegisterFunctionDelegate <Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterFunctionDelegate <System.Threading.Tasks.Task>(); // 注册适配器 appdomain.RegisterCrossBindingAdaptor(new Adapt_IMessage()); appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <float, float>(); appdomain.DelegateManager.RegisterMethodDelegate <float, float, float>(); appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, byte, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <EventContext>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback0>((act) => { return(new FairyGUI.EventCallback0(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback1>((act) => { return(new FairyGUI.EventCallback1((context) => { ((Action <FairyGUI.EventContext>)act)(context); })); }); 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); }
public static void InitILRuntime(AppDomain appDomain) { //TODO:注册重定向方法 //TODO:适配委托 appDomain.DelegateManager.RegisterMethodDelegate <float>(); appDomain.DelegateManager.RegisterMethodDelegate <object, GameFramework.Event.GameEventArgs>(); //TODO:注册委托 appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction>((action) => { return(new UnityAction(() => { ((Action)action)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction <float> >((action) => { return(new UnityAction <float>((a) => { ((Action <float>)action)(a); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <GameFramework.Event.GameEventArgs> >((act) => { return(new System.EventHandler <GameFramework.Event.GameEventArgs>((sender, e) => { ((Action <System.Object, GameFramework.Event.GameEventArgs>)act)(sender, e); })); }); //注册CLR绑定代码 CLRBindings.Initialize(appDomain); //TODO:注册适配器 appDomain.RegisterCrossBindingAdaptor(new GameEventArgsAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IReferenceAdaptor()); //注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
void InitializeILRuntime() { //这里做一些ILRuntime的注册,HelloWorld示例暂时没有需要注册的 appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterMethodDelegate <NetBase, System.Byte[], System.Int32>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Boolean>(); appdomain.DelegateManager.RegisterMethodDelegate <System.IAsyncResult>(); appdomain.DelegateManager.RegisterDelegateConvertor <System.AsyncCallback>((act) => { return(new System.AsyncCallback((ar) => { ((Action <System.IAsyncResult>)act)(ar); })); }); appdomain.DelegateManager.RegisterMethodDelegate <System.Int32, System.Byte[]>(); appdomain.DelegateManager.RegisterDelegateConvertor <System.Threading.ThreadStart>((act) => { return(new System.Threading.ThreadStart(() => { ((Action)act)(); })); }); //====proto======= appdomain.RegisterCrossBindingAdaptor(new Adapt_IMessage()); appdomain.DelegateManager.RegisterFunctionDelegate <Adapt_IMessage.Adaptor>(); appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); //预先获得IMethod,可以减低每次调用查找方法耗用的时间 IType type = appdomain.LoadedTypes["HotFix_Project.Main"]; //根据方法名称和参数个数获取方法 method = type.GetMethod("Run", 0); method_update = type.GetMethod("Update", 0); method_out = type.GetMethod("Out", 0); }
void InitializeILRuntime() { //这里做一些ILRuntime的注册,HelloWorld示例暂时没有需要注册的 //UGUI 委托 appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((System.Action)act)(); })); }); appDomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); appDomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); SetupCLRRedirection(); SetupCLRRedirection2(); }
//======================================================================== //注册函数 //======================================================================== public void RegisterCrossBindingAdaptor(CrossBindingAdaptor adaptor) { if (m_appdomain != null) { m_appdomain.RegisterCrossBindingAdaptor(adaptor); } else { Debuger.LogError("ILRuntime的AppDomain未创建!"); } }