123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using ILRuntime.Runtime.Intepreter;
- using ILRuntime.Runtime.Stack;
- using ILRuntime.CLR.Method;
- using ILRuntime.CLR.TypeSystem;
- using System.Reflection;
- using ILRuntime.CLR.Utils;
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class ILRuntimeHelper
- {
- public unsafe static void RegisterILRuntimeCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
- {
- //重定向
- LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain);
- CLRMethod(appdomain);
- }
- private unsafe static void CLRMethod(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
- {
- BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
- MethodBase method;
- Type[] args;
- Type type = typeof(FairyGUI.UIObjectFactory);
- args = new Type[] { typeof(System.String), typeof(System.Type) };
- method = type.GetMethod("SetPackageItemExtension", flag, null, args, null);
- appdomain.RegisterCLRMethodRedirection(method, SetPackageItemExtension_0);
- }
- private unsafe static StackObject* SetPackageItemExtension_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
- {
- ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
- StackObject* ptr_of_this_method;
- StackObject* __ret = ILIntepreter.Minus(__esp, 2);
- ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
- System.Type @type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
- __intp.Free(ptr_of_this_method);
- ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
- System.String @url = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
- __intp.Free(ptr_of_this_method);
- FairyGUI.UIObjectFactory.SetPackageItemExtension(@url, () => {
- Debug.Log("il test " + @type.FullName);
- return __domain.Instantiate<GComponent>(@type.FullName);
- });
- // FairyGUI.UIObjectFactory.SetPackageItemExtension (@url, @type);
- return __ret;
- }
- }
- }
|