Пример #1
0
        public ReflectionMethodsCache()
        {
            System.Type[] types  = new System.Type[] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int) };
            MethodInfo    method = typeof(Physics).GetMethod("Raycast", types);

            if (method != null)
            {
                this.raycast3D = (Raycast3DCallback)ScriptingUtils.CreateDelegate(typeof(Raycast3DCallback), method);
            }
            System.Type[] typeArray2 = new System.Type[] { typeof(Vector2), typeof(Vector2), typeof(float), typeof(int) };
            MethodInfo    methodInfo = typeof(Physics2D).GetMethod("Raycast", typeArray2);

            if (methodInfo != null)
            {
                this.raycast2D = (Raycast2DCallback)ScriptingUtils.CreateDelegate(typeof(Raycast2DCallback), methodInfo);
            }
            System.Type[] typeArray3 = new System.Type[] { typeof(Ray), typeof(float), typeof(int) };
            MethodInfo    info3      = typeof(Physics).GetMethod("RaycastAll", typeArray3);

            if (info3 != null)
            {
                this.raycast3DAll = (RaycastAllCallback)ScriptingUtils.CreateDelegate(typeof(RaycastAllCallback), info3);
            }
            System.Type[] typeArray4 = new System.Type[] { typeof(Ray), typeof(float), typeof(int) };
            MethodInfo    info4      = typeof(Physics2D).GetMethod("GetRayIntersectionAll", typeArray4);

            if (info4 != null)
            {
                this.getRayIntersectionAll = (GetRayIntersectionAllCallback)ScriptingUtils.CreateDelegate(typeof(GetRayIntersectionAllCallback), info4);
            }
        }
 public ReflectionMethodsCache()
 {
     System.Type[] types = new System.Type[] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int) };
     MethodInfo method = typeof(Physics).GetMethod("Raycast", types);
     if (method != null)
     {
         this.raycast3D = (Raycast3DCallback) ScriptingUtils.CreateDelegate(typeof(Raycast3DCallback), method);
     }
     System.Type[] typeArray2 = new System.Type[] { typeof(Vector2), typeof(Vector2), typeof(float), typeof(int) };
     MethodInfo methodInfo = typeof(Physics2D).GetMethod("Raycast", typeArray2);
     if (methodInfo != null)
     {
         this.raycast2D = (Raycast2DCallback) ScriptingUtils.CreateDelegate(typeof(Raycast2DCallback), methodInfo);
     }
     System.Type[] typeArray3 = new System.Type[] { typeof(Ray), typeof(float), typeof(int) };
     MethodInfo info3 = typeof(Physics).GetMethod("RaycastAll", typeArray3);
     if (info3 != null)
     {
         this.raycast3DAll = (RaycastAllCallback) ScriptingUtils.CreateDelegate(typeof(RaycastAllCallback), info3);
     }
     System.Type[] typeArray4 = new System.Type[] { typeof(Ray), typeof(float), typeof(int) };
     MethodInfo info4 = typeof(Physics2D).GetMethod("GetRayIntersectionAll", typeArray4);
     if (info4 != null)
     {
         this.getRayIntersectionAll = (GetRayIntersectionAllCallback) ScriptingUtils.CreateDelegate(typeof(GetRayIntersectionAllCallback), info4);
     }
 }
Пример #3
0
        public ReflectionMethodsCache()
        {
            var raycast3DMethodInfo = typeof(Physics).GetMethod("Raycast",
                                                                new[] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int) });

            if (raycast3DMethodInfo != null)
            {
                raycast3D = (Raycast3DCallback)UnityEngineInternal.ScriptingUtils.CreateDelegate(
                    typeof(Raycast2DCallback), raycast3DMethodInfo);
            }
        }
Пример #4
0
        public ReflectionMethodsCache()
        {
            MethodInfo method = typeof(Physics).GetMethod("Raycast", new Type[4]
            {
                typeof(Ray),
                typeof(RaycastHit).MakeByRefType(),
                typeof(float),
                typeof(int)
            });

            if (method != null)
            {
                raycast3D = (Raycast3DCallback)ScriptingUtils.CreateDelegate(typeof(Raycast3DCallback), method);
            }
            MethodInfo method2 = typeof(Physics2D).GetMethod("Raycast", new Type[4]
            {
                typeof(Vector2),
                typeof(Vector2),
                typeof(float),
                typeof(int)
            });

            if (method2 != null)
            {
                raycast2D = (Raycast2DCallback)ScriptingUtils.CreateDelegate(typeof(Raycast2DCallback), method2);
            }
            MethodInfo method3 = typeof(Physics).GetMethod("RaycastAll", new Type[3]
            {
                typeof(Ray),
                typeof(float),
                typeof(int)
            });

            if (method3 != null)
            {
                raycast3DAll = (RaycastAllCallback)ScriptingUtils.CreateDelegate(typeof(RaycastAllCallback), method3);
            }
            MethodInfo method4 = typeof(Physics2D).GetMethod("GetRayIntersectionAll", new Type[3]
            {
                typeof(Ray),
                typeof(float),
                typeof(int)
            });

            if (method4 != null)
            {
                getRayIntersectionAll = (GetRayIntersectionAllCallback)ScriptingUtils.CreateDelegate(typeof(GetRayIntersectionAllCallback), method4);
            }
        }
Пример #5
0
        // We call Physics.Raycast and Physics2D.Raycast through reflection to avoid creating a hard dependency from
        // this class to the Physics/Physics2D modules, which would otherwise make it impossible to make content with UI
        // without force-including both modules.
        //
        // *NOTE* If other methods are required ensure to add [RequiredByNativeCode] to the bindings for that function. It prevents
        //        the function from being stripped if required. See Dynamics.bindings.cs for examples (search for GraphicRaycaster.cs).
        public ReflectionMethodsCache()
        {
#if PACKAGE_PHYSICS
            var raycast3DMethodInfo = typeof(Physics).GetMethod("Raycast", new[] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int) });
            if (raycast3DMethodInfo != null)
            {
                raycast3D = (Raycast3DCallback)Delegate.CreateDelegate(typeof(Raycast3DCallback), raycast3DMethodInfo);
            }

            var raycastAllMethodInfo = typeof(Physics).GetMethod("RaycastAll", new[] { typeof(Ray), typeof(float), typeof(int) });
            if (raycastAllMethodInfo != null)
            {
                raycast3DAll = (RaycastAllCallback)Delegate.CreateDelegate(typeof(RaycastAllCallback), raycastAllMethodInfo);
            }

            var getRaycastAllNonAllocMethodInfo = typeof(Physics).GetMethod("RaycastNonAlloc", new[] { typeof(Ray), typeof(RaycastHit[]), typeof(float), typeof(int) });
            if (getRaycastAllNonAllocMethodInfo != null)
            {
                getRaycastNonAlloc = (GetRaycastNonAllocCallback)Delegate.CreateDelegate(typeof(GetRaycastNonAllocCallback), getRaycastAllNonAllocMethodInfo);
            }
#endif
#if PACKAGE_PHYSICS2D
            var raycast2DMethodInfo = typeof(Physics2D).GetMethod("Raycast", new[] { typeof(Vector2), typeof(Vector2), typeof(float), typeof(int) });
            if (raycast2DMethodInfo != null)
            {
                raycast2D = (Raycast2DCallback)Delegate.CreateDelegate(typeof(Raycast2DCallback), raycast2DMethodInfo);
            }

            var getRayIntersectionAllMethodInfo = typeof(Physics2D).GetMethod("GetRayIntersectionAll", new[] { typeof(Ray), typeof(float), typeof(int) });
            if (getRayIntersectionAllMethodInfo != null)
            {
                getRayIntersectionAll = (GetRayIntersectionAllCallback)Delegate.CreateDelegate(typeof(GetRayIntersectionAllCallback), getRayIntersectionAllMethodInfo);
            }

            var getRayIntersectionAllNonAllocMethodInfo = typeof(Physics2D).GetMethod("GetRayIntersectionNonAlloc", new[] { typeof(Ray), typeof(RaycastHit2D[]), typeof(float), typeof(int) });
            if (getRayIntersectionAllNonAllocMethodInfo != null)
            {
                getRayIntersectionAllNonAlloc = (GetRayIntersectionAllNonAllocCallback)Delegate.CreateDelegate(typeof(GetRayIntersectionAllNonAllocCallback), getRayIntersectionAllNonAllocMethodInfo);
            }
#endif
        }