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); }
public static void registeCrossAdaptor(ILRAppDomain appDomain) { appDomain.RegisterCrossBindingAdaptor(new FrameBaseAdapter()); appDomain.RegisterCrossBindingAdaptor(new GameSceneAdapter()); appDomain.RegisterCrossBindingAdaptor(new LayoutScriptAdapter()); appDomain.RegisterCrossBindingAdaptor(new SceneProcedureAdapter()); appDomain.RegisterCrossBindingAdaptor(new CharacterAdapter()); appDomain.RegisterCrossBindingAdaptor(new CharacterBaseDataAdapter()); appDomain.RegisterCrossBindingAdaptor(new GameComponentAdapter()); appDomain.RegisterCrossBindingAdaptor(new StateParamAdapter()); appDomain.RegisterCrossBindingAdaptor(new PlayerStateAdapter()); appDomain.RegisterCrossBindingAdaptor(new StateGroupAdapter()); appDomain.RegisterCrossBindingAdaptor(new CommandAdapter()); appDomain.RegisterCrossBindingAdaptor(new SQLiteTableAdapter()); appDomain.RegisterCrossBindingAdaptor(new SQLiteDataAdapter()); appDomain.RegisterCrossBindingAdaptor(new PooledWindowAdapter()); appDomain.RegisterCrossBindingAdaptor(new SceneInstanceAdapter()); appDomain.RegisterCrossBindingAdaptor(new FrameSystemAdapter()); appDomain.RegisterCrossBindingAdaptor(new TransformableAdapter()); // 值类型绑定 appDomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); appDomain.RegisterValueTypeBinder(typeof(Vector2Int), new Vector2IntBinder()); appDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appDomain.RegisterValueTypeBinder(typeof(Vector3Int), new Vector3IntBinder()); }
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()); domain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); domain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); }
public static void Init(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { // 注册委托 appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterMethodDelegate <NetReceivePackage>(); appDomain.DelegateManager.RegisterMethodDelegate <MotionEngine.Event.IEventMessage>(); appDomain.DelegateManager.RegisterMethodDelegate <MotionEngine.Res.Asset, MotionEngine.Res.EAssetResult>(); appDomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapter_IMessage.Adaptor>(); appDomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapter_IMessage.Adaptor>(); // 注册委托转换器 appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); // 注册值类型绑定器 appDomain.RegisterValueTypeBinder(typeof(UnityEngine.Vector2), new Vector2Binder()); appDomain.RegisterValueTypeBinder(typeof(UnityEngine.Vector3), new Vector3Binder()); appDomain.RegisterValueTypeBinder(typeof(UnityEngine.Quaternion), new QuaternionBinder()); // 执行CLR绑定 //ILRuntime.Runtime.Generated.CLRBindings.Initialize(appDomain); Type classCLRBinding = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); if (classCLRBinding != null) { var method = classCLRBinding.GetMethod("Initialize"); method.Invoke(null, new object[] { appDomain }); } else { MotionEngine.LogSystem.Log(MotionEngine.ELogType.Warning, "ILRuntime not generated binding scripts."); } // 注册适配器 Google.Protobuf.Adapter_IMessage adaptor = new Google.Protobuf.Adapter_IMessage(); appDomain.RegisterCrossBindingAdaptor(adaptor); // 注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
void init() { //值类型绑定 appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); //委托绑定 appdomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appdomain.DelegateManager.RegisterDelegateConvertor <TestDelegate>((act) => { return(new TestDelegate((intarg) => { ((Action <System.Int32>)act)(intarg); })); }); //重定向 CLRBindings.Initialize(appdomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 domain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); domain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); domain.RegisterCrossBindingAdaptor(new IGuiAdapter()); domain.RegisterCrossBindingAdaptor(new ServiceBaseAdaptor()); domain.RegisterCrossBindingAdaptor(new BaseCtrlAdaptor()); domain.RegisterCrossBindingAdaptor(new ViewModelBaseAdaptor()); }
private void OnBtnLoad(object sender, EventArgs e) { if (txtPath.Text == "") { if (OD.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["assembly_path"] = txtPath.Text = OD.FileName; Properties.Settings.Default.Save(); } else { return; } } try { using (FileStream fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read)) { var path = Path.GetDirectoryName(txtPath.Text); var name = Path.GetFileNameWithoutExtension(txtPath.Text); using (var fs2 = new System.IO.FileStream($"{path}\\{name}.pdb", FileMode.Open)) { _app.LoadAssembly(fs, fs2, new Mono.Cecil.Pdb.PdbReaderProvider()); _isLoadAssembly = true; } ILRuntimeHelper.Init(_app); _app.RegisterValueTypeBinder(typeof(TestVector3), new TestVector3Binder()); _app.RegisterValueTypeBinder(typeof(TestVectorStruct), new TestVectorStructBinder()); _app.RegisterValueTypeBinder(typeof(TestVectorStruct2), new TestVectorStruct2Binder()); LoadTest(); UpdateBtnState(); } } catch (Exception ex) { MessageBox.Show("[Error:]" + ex); } }
private void InitializeILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { Debug.Log("InitializeILRuntime"); appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <Vector2> >((act) => { return(new UnityEngine.Events.UnityAction <Vector2>((arg0) => { ((Action <Vector2>)act)(arg0); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public IXILRuntime RegisterValueTypeBinder(Type type, ValueTypeBinder binder) { m_AppDomain?.RegisterValueTypeBinder(type, binder); return(this); }
public static void InitILRuntime(AppDomain appDomain) { //TODO:注册重定向方法 //TODO:适配委托 //GF用 appDomain.DelegateManager.RegisterMethodDelegate <float>(); appDomain.DelegateManager.RegisterMethodDelegate <object, ILTypeInstance>(); //ET用 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 <Session, ushort, MemoryStream>(); //PB用 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 <EventHandler <GameFramework.Event.GameEventArgs> >((act) => { return(new EventHandler <GameFramework.Event.GameEventArgs>((sender, e) => { ((Action <object, GameFramework.Event.GameEventArgs>)act)(sender, e); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <EventHandler <ILTypeInstance> >((act) => { return(new EventHandler <ILTypeInstance>((sender, e) => { ((Action <object, ILTypeInstance>)act)(sender, e); })); }); //注册CLR绑定代码 CLRBindings.Initialize(appDomain); //TODO:注册跨域继承适配器 appDomain.RegisterCrossBindingAdaptor(new IMessageAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IDisposableAdaptor()); appDomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineAdaptor()); //TODO:注册值类型绑定 appDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appDomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); //注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
public static void InitILRuntime(AppDomain appdomain) { //TODO:注册重定向方法 appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); //TODO:适配委托 appdomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Boolean>(); appdomain.DelegateManager.RegisterMethodDelegate <Vector3>(); appdomain.DelegateManager.RegisterMethodDelegate <Vector2>(); appdomain.DelegateManager.RegisterMethodDelegate <Vector2Int>(); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Vector2, System.Single>(); appdomain.DelegateManager .RegisterMethodDelegate <System.String, System.Object, System.Single, System.Object>(); appdomain.DelegateManager .RegisterMethodDelegate <System.String, GameFramework.Resource.LoadResourceStatus, System.String, System.Object>(); appdomain.DelegateManager.RegisterFunctionDelegate <System.Boolean>(); //GF用 appdomain.DelegateManager.RegisterMethodDelegate <float>(); appdomain.DelegateManager.RegisterMethodDelegate <object, ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <object, GameFramework.Event.GameEventArgs>(); //ET用 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 <Session, ushort, MemoryStream>(); //PB用 appdomain.DelegateManager.RegisterFunctionDelegate <IMessageAdaptor.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <IMessageAdaptor.Adaptor>(); //HotFixUI用 appdomain.DelegateManager.RegisterMethodDelegate <Fuse.HotfixUGuiForm, System.Object>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject, System.Object>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Object>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Boolean, System.Object>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Single, System.Single>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Int32, System.Int32>(); appdomain.DelegateManager.RegisterFunctionDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.Vector2> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.Vector2>((arg0) => { ((Action <UnityEngine.Vector2>)act)(arg0); })); }); //HotFixEntity用 appdomain.DelegateManager.RegisterMethodDelegate <Fuse.HotfixEntityLogic, System.Object>(); appdomain.DelegateManager .RegisterMethodDelegate <UnityGameFramework.Runtime.EntityLogic, UnityEngine.Transform, System.Object>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityGameFramework.Runtime.EntityLogic, System.Object>(); appdomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance>((obj) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>)act)(obj); })); }); #region EventListener appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.EventSystems.PointerEventData>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.EventSystems.BaseEventData>(); appdomain.DelegateManager.RegisterDelegateConvertor <global::Fuse.EventListener.PointerDataDelegate>((act) => { return(new global::Fuse.EventListener.PointerDataDelegate((eventData) => { ((Action <UnityEngine.EventSystems.PointerEventData>)act)(eventData); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <global::Fuse.EventListener.BaseDataDelegate>((act) => { return(new global::Fuse.EventListener.BaseDataDelegate((eventData) => { ((Action <UnityEngine.EventSystems.BaseEventData>)act)(eventData); })); }); #endregion #region DOTween appdomain.DelegateManager.RegisterDelegateConvertor <DG.Tweening.TweenCallback>((act) => { return(new DG.Tweening.TweenCallback(() => { ((Action)act)(); })); }); #endregion //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 <EventHandler <GameFramework.Event.GameEventArgs> >((act) => { return(new EventHandler <GameFramework.Event.GameEventArgs>((sender, e) => { ((Action <object, GameFramework.Event.GameEventArgs>)act)(sender, e); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <EventHandler <ILTypeInstance> >((act) => { return(new EventHandler <ILTypeInstance>((sender, e) => { ((Action <object, ILTypeInstance>)act)(sender, e); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <GameFramework.Resource.LoadAssetSuccessCallback>((act) => { return(new GameFramework.Resource.LoadAssetSuccessCallback((assetName, asset, duration, userData) => { ((Action <System.String, System.Object, System.Single, System.Object>)act)(assetName, asset, duration, userData); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <GameFramework.Resource.LoadAssetFailureCallback>((act) => { return(new GameFramework.Resource.LoadAssetFailureCallback((assetName, status, errorMessage, userData) => { ((Action <System.String, GameFramework.Resource.LoadResourceStatus, System.String, System.Object>)act) (assetName, status, errorMessage, userData); })); }); appdomain.DelegateManager.RegisterMethodDelegate <System.IAsyncResult>(); appdomain.DelegateManager.RegisterDelegateConvertor <System.AsyncCallback>((act) => { return(new System.AsyncCallback((ar) => { ((Action <System.IAsyncResult>)act)(ar); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <System.Threading.ThreadStart>((act) => { return(new System.Threading.ThreadStart(() => { ((Action)act)(); })); }); //注册CLR绑定代码 CLRBindings.Initialize(appdomain); //TODO:注册跨域继承适配器 appdomain.RegisterCrossBindingAdaptor(new IMessageAdaptor()); appdomain.RegisterCrossBindingAdaptor(new IDisposableAdaptor()); appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineAdaptor()); //TODO:注册值类型绑定 appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); //注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { appDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); // 注册重定向函数 // 注册委托适配器 appDomain.DelegateManager.RegisterMethodDelegate <ETVoid>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Int64>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Single>(); //float appDomain.DelegateManager.RegisterMethodDelegate <System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <System.String, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Boolean, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <int, int, bool>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Single, System.Single>(); appDomain.DelegateManager.RegisterMethodDelegate <List <System.Object> >(); appDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Byte[], System.Int32, System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <System.UInt16, Google.Protobuf.IMessage>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, System.Object>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, System.UInt16, MemoryStream>(); appDomain.DelegateManager.RegisterMethodDelegate <Session>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Byte[]>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.UInt16, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Exception>(); appDomain.DelegateManager.RegisterMethodDelegate <HYZ.Cfg.ETModel.NoviceguideDefine>(); appDomain.DelegateManager.RegisterMethodDelegate <HYZ.Cfg.ETModel.GuideHandle>(); appDomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Vector2>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Video.VideoPlayer>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.UI.Text>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.TabGroup, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Collections.IEnumerator>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Collections.IEnumerator, System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Object>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.BaseSystem>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, ETModel.Match.AnimRunMatchState>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.String, System.Boolean, System.Int32, System.Double>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.String, System.Int32, System.Double>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, HYZ.Cfg.ETModel.SkillTriggerContent, System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <HorseListItem>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Double>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Single, System.Single>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Int32, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, ILTypeInstance, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.ChallengeDefine, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.EquipmentMaterialList, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.MatchPlayer, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseRunData, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, ETModel.Match.Path>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.Path[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <List <ETModel.Match.HorseRunData> >(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Random>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Double, System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Double, System.Double, System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.MatchConst>(); appDomain.DelegateManager.RegisterFunctionDelegate <List <System.Int32> >(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.Match>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.tabtoy.DataProxyComponent>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseBuffManager>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseRunData, ETModel.Match.HorseRunData, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.IO.FileInfo, System.IO.FileInfo, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64, System.Int64, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Collections.IEnumerator, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Collections.IEnumerator>(); appDomain.DelegateManager.RegisterFunctionDelegate <HorseListItem, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.CameraPathState, int, int, Transform>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.HorseLevelUpDefine, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.DualwingiftDefine, System.Boolean>(); // 注册委托转换器 appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.UInt16, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Exception>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Byte[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.DualConfigDefine, System.Boolean>(); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.DualwingiftDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.DualwingiftDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.DualwingiftDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.DualConfigDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.DualConfigDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.DualConfigDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.HorseLevelUpDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.HorseLevelUpDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.HorseLevelUpDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketOpenDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketOpenDelegate((webSocket) => { ((Action <BestHTTP.WebSocket.WebSocket>)act)(webSocket); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <global::HorseListItem> >((act) => { return(new System.Predicate <global::HorseListItem>((obj) => { return ((Func <global::HorseListItem, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketMessageDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketMessageDelegate((webSocket, message) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketBinaryDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketBinaryDelegate((webSocket, data) => { ((Action <BestHTTP.WebSocket.WebSocket, byte[]>)act)(webSocket, data); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketClosedDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketClosedDelegate((webSocket, code, message) => { ((Action <BestHTTP.WebSocket.WebSocket, UInt16, string>)act)(webSocket, code, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDelegate((webSocket, ex) => { ((Action <BestHTTP.WebSocket.WebSocket, System.Exception>)act)(webSocket, ex); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate((webSocket, reason) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, reason); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ETModel.Match.MatchPlayer> >((act) => { return(new System.Predicate <ETModel.Match.MatchPlayer>((obj) => { return ((Func <ETModel.Match.MatchPlayer, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ETModel.Match.HorseRunData> >((act) => { return(new System.Predicate <ETModel.Match.HorseRunData>((obj) => { return ((Func <ETModel.Match.HorseRunData, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData>((arg0) => { ((Action <UnityEngine.EventSystems.BaseEventData>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int32> >((act) => { return(new System.Predicate <System.Int32>((obj) => { return ((Func <System.Int32, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.OnRequestFinishedDelegate>((act) => { return(new BestHTTP.OnRequestFinishedDelegate((originalRequest, response) => { ((Action <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>)act)(originalRequest, response); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { //((Action<>)act)(); ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <DG.Tweening.TweenCallback>((act) => { return(new DG.Tweening.TweenCallback(() => { ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <Quick.UI.Tab.PointerTabFunc>((act) => { return(new Quick.UI.Tab.PointerTabFunc((target, eventData) => { ((Action <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>)act)(target, eventData); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.String> >((act) => { return(new UnityEngine.Events.UnityAction <System.String>((arg0) => { ((Action <System.String>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance>((obj) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Video.VideoPlayer.EventHandler>((act) => { return(new UnityEngine.Video.VideoPlayer.EventHandler((source) => { ((Action <UnityEngine.Video.VideoPlayer>)act)(source); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.Vector2> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.Vector2>((arg0) => { ((Action <UnityEngine.Vector2>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance>((x, y) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.IO.FileInfo> >((act) => { return(new System.Comparison <System.IO.FileInfo>((x, y) => { return ((Func <System.IO.FileInfo, System.IO.FileInfo, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.Int64> >((act) => { return(new System.Comparison <System.Int64>((x, y) => { return ((Func <System.Int64, System.Int64, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Boolean> >((act) => { return(new UnityEngine.Events.UnityAction <System.Boolean>((arg0) => { ((Action <System.Boolean>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.Int32> >((act) => { return(new System.Comparison <System.Int32>((x, y) => { return ((Func <System.Int32, System.Int32, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <ETModel.Match.HorseRunData> >((act) => { return(new System.Comparison <ETModel.Match.HorseRunData>((x, y) => { return ((Func <ETModel.Match.HorseRunData, ETModel.Match.HorseRunData, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Int32> >((act) => { return(new UnityEngine.Events.UnityAction <System.Int32>((arg0) => { ((Action <System.Int32>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Single> >((act) => { return(new UnityEngine.Events.UnityAction <System.Single>((arg0) => { ((Action <System.Single>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.ChallengeDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.ChallengeDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.ChallengeDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.EquipmentMaterialList> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.EquipmentMaterialList>((obj) => { return ((Func <HYZ.Cfg.ETModel.EquipmentMaterialList, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64> >((act) => { return(new System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>((input) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>)act)(input); })); }); 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); } // 初始化ILRuntime的protobuf InitializeILRuntimeProtobuf(appDomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); //ILSerial.RegisterILRuntimeCLRRedirection(appDomain); }
public static void Register(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册Action appdomain.DelegateManager.RegisterMethodDelegate <float>(); appdomain.DelegateManager.RegisterMethodDelegate <bool>(); appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Network.INetworkPackage>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Event.IEventMessage>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Resource.AssetOperationHandle>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Resource.SceneInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Config.AssetConfig>(); appdomain.DelegateManager.RegisterMethodDelegate <MotionFramework.Pool.SpawnGameObject>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); // 注册Func appdomain.DelegateManager.RegisterFunctionDelegate <float, float, float, float, float>(); appdomain.DelegateManager.RegisterFunctionDelegate <float, float, float, float> (); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Vector2, UnityEngine.Vector2, float, UnityEngine.Vector2>(); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Vector3, UnityEngine.Vector3, float, UnityEngine.Vector3>(); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Vector4, UnityEngine.Vector4, float, UnityEngine.Vector4>(); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Color, UnityEngine.Color, float, UnityEngine.Color>(); appdomain.DelegateManager.RegisterFunctionDelegate <UnityEngine.Quaternion, UnityEngine.Quaternion, float, UnityEngine.Quaternion>(); // 注册委托转换器 appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <float> >((act) => { return(new UnityEngine.Events.UnityAction <float>((arg0) => { ((Action <float>)act)(arg0); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <bool> >((act) => { return(new UnityEngine.Events.UnityAction <bool>((arg0) => { ((Action <bool>)act)(arg0); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <MotionFramework.Tween.TweenNode <UnityEngine.Vector2> .TweenLerpDelegate>((act) => { return(new MotionFramework.Tween.TweenNode <UnityEngine.Vector2> .TweenLerpDelegate((from, to, progress) => { return ((Func <UnityEngine.Vector2, UnityEngine.Vector2, System.Single, UnityEngine.Vector2>)act)(from, to, progress); })); }); // 注册值类型绑定器 appdomain.RegisterValueTypeBinder(typeof(UnityEngine.Vector2), new Vector2Binder()); appdomain.RegisterValueTypeBinder(typeof(UnityEngine.Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(UnityEngine.Quaternion), new QuaternionBinder()); // 注册适配器 appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); appdomain.RegisterCrossBindingAdaptor(new CanvasWindowAdapter()); appdomain.RegisterCrossBindingAdaptor(new Google.Protobuf.IMessageAdapter()); appdomain.RegisterCrossBindingAdaptor(new MotionFramework.AI.IFsmNodeAdapter()); appdomain.RegisterCrossBindingAdaptor(new MotionFramework.Event.IEventMessageAdapter()); appdomain.RegisterCrossBindingAdaptor(new MotionFramework.Config.AssetConfigAdapter()); appdomain.RegisterCrossBindingAdaptor(new MotionFramework.Config.ConfigTableAdapter()); // 执行CLR绑定 //ILRuntime.Runtime.Generated.CLRBindings.Initialize(appDomain); Type classCLRBinding = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); if (classCLRBinding != null) { var method = classCLRBinding.GetMethod("Initialize"); method.Invoke(null, new object[] { appdomain }); } else { GameLog.Warning("ILRuntime not generated binding scripts."); // 注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); } }