protected override int DoCast(Ray ray, RaycastHit[] hitArray) { var scale = transform.lossyScale; if (maxResults == 1) { #if UNITY_2019_1_OR_NEWER return(PhysicsScene. #else return Physics. #endif BoxCast(ray.origin, PhysicsSensorUtils.GetScaledBoxRadius(halfExtents, scale), ray.direction, out hitArray[0], transform.rotation, PhysicsSensorUtils.GetCastDistance(maxDistance, scale), layerMask, queryTriggerInteraction) ? 1 : 0); } #if UNITY_2019_1_OR_NEWER return(PhysicsScene.BoxCast #else return Physics.BoxCastNonAlloc #endif (ray.origin, PhysicsSensorUtils.GetScaledBoxRadius(halfExtents, scale), ray.direction, hitArray, transform.rotation, PhysicsSensorUtils.GetCastDistance(maxDistance, scale), layerMask, queryTriggerInteraction)); }
protected override int DoCast(Ray ray, RaycastHit[] hitArray) { var scale = transform.lossyScale; var castDistance = PhysicsSensorUtils.GetCastDistance(maxDistance, scale); if (width != 0) { Vector3 p1; Vector3 p2; PhysicsSensorUtils.GetCapsulePoints(ray.origin, transform.rotation, width, scale.x, out p1, out p2); if (hitArray.Length == 1) { return(Physics.CapsuleCast(p1, p2, PhysicsSensorUtils.GetScaledCapsuleRadius(radius, scale), ray.direction, out hitArray[0], castDistance, layerMask, queryTriggerInteraction) ? 1 : 0); } return(Physics.CapsuleCastNonAlloc(p1, p2, PhysicsSensorUtils.GetScaledCapsuleRadius(radius, scale), ray.direction, hitArray, castDistance, layerMask, queryTriggerInteraction)); } if (radius != 0) { if (hitArray.Length == 1) { return(Physics.SphereCast(Ray, PhysicsSensorUtils.GetScaledSphereRadius(radius, scale), out hitArray[0], castDistance, layerMask, queryTriggerInteraction) ? 1 : 0); } return(Physics.SphereCastNonAlloc(Ray, PhysicsSensorUtils.GetScaledSphereRadius(radius, scale), hitArray, castDistance, layerMask, queryTriggerInteraction)); } if (hitArray.Length == 1) { return(Physics.Raycast(Ray, out hitArray[0], castDistance, layerMask, queryTriggerInteraction) ? 1 : 0); } return(Physics.RaycastNonAlloc(Ray, hitArray, castDistance, layerMask, queryTriggerInteraction)); }