示例#1
0
        static void InitializeILRuntime()
        {
#if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE)
            //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler
            appdomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
#endif
            ILRuntimeDelegateHelper.RegisterDelegate(appdomain);
            ILRuntimeAdapterHelper.RegisterCrossBindingAdaptor(appdomain);
            ILRuntimeRedirectHelper.RegisterMethodRedirection(appdomain);
            ILRuntimeValueTypeBinderHelper.Register(appdomain);

            //初始化CLR绑定请放在初始化的最后一步!!
            //初始化CLR绑定请放在初始化的最后一步!!
            //初始化CLR绑定请放在初始化的最后一步!!

            //请在生成了绑定代码后解除下面这行的注释
            //请在生成了绑定代码后解除下面这行的注释
            //请在生成了绑定代码后解除下面这行的注释
            //ILRuntime.Runtime.Generated.CLRBindings.Initialize(appdomain);
        }
示例#2
0
        public static void InitializeILRuntime(AppDomain appDomain)
        {
#if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE)
            //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler
            appDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
#endif
            ILRuntimeDelegateHelper.RegisterDelegate(appDomain);
            ILRuntimeAdapterHelper.RegisterCrossBindingAdaptor(appDomain);
            ILRuntimeRedirectHelper.RegisterMethodRedirection(appDomain);
            ILRuntimeValueTypeBinderHelper.Register(appDomain);
            ILRuntimeGenericHelper.RegisterGenericFunc(appDomain);
            LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain);

            //初始化CLR绑定请放在初始化的最后一步!!
            Type t = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings");
            if (t != null)
            {
                t.GetMethod("Initialize")?.Invoke(null, new object[] { appDomain });
            }
        }