コード例 #1
0
 void OnDrawGizmos()
 {
     if (map2D == null)
     {
         return;
     }
     DebugPhysics.DrawGizmos(map2D);
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        // Raycasts.
        if (DoRaycast)
        {
            if (DebugPhysics.Raycast(transform.position, transform.forward, RayCastLength))
            {
            }
        }
        if (DoRaycastHit)
        {
            RaycastHit hit;
            if (DebugPhysics.Raycast(transform.position, transform.forward, out hit, RayCastLength))
            {
            }
        }
        if (DoRayCastAll)
        {
            RaycastHit[] hits = DebugPhysics.RaycastAll(transform.position, transform.forward, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                //do something
            }
        }
        if (DoRayCastAllNonAlloc)
        {
            RaycastHit[] hits = new RaycastHit[10];
            DebugPhysics.RaycastNonAlloc(transform.position, transform.forward, hits, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                //do something
            }
        }


        if (DoSphereCast)
        {
            if (DebugPhysics.SphereCast(new Ray(this.transform.position, this.transform.forward), SphereCastRadius, RayCastLength))
            {
            }
        }
        if (DoSphereCastHit)
        {
            RaycastHit hit;
            if (DebugPhysics.SphereCast(transform.position, SphereCastRadius, this.transform.forward, out hit, RayCastLength))
            {
            }
        }
        if (DoSphereCastAll)
        {
            RaycastHit[] hits = DebugPhysics.SphereCastAll(transform.position, SphereCastRadius, this.transform.forward, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                // do something
            }
        }
        if (DoSphereCastAllNonAlloc)
        {
            RaycastHit[] hits = new RaycastHit[10];
            DebugPhysics.SphereCastNonAlloc(transform.position, SphereCastRadius, transform.forward, hits, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                // do something
            }
        }

        if (DoLinecast)
        {
            if (DebugPhysics.Linecast(transform.position, transform.position + transform.forward * RayCastLength))
            {
                // do something
            }
        }
        if (DoLinecastHit)
        {
            RaycastHit hit;
            if (DebugPhysics.Linecast(transform.position, transform.position + transform.forward * RayCastLength, out hit))
            {
                // do something
            }
        }

        if (DoBoxCast)
        {
            if (DebugPhysics.BoxCast(transform.position, BoxCastHalfExtents, transform.forward, transform.rotation, RayCastLength))
            {
                // do something
            }
        }

        if (DoBoxCastHit)
        {
            RaycastHit hit;
            if (DebugPhysics.BoxCast(transform.position, BoxCastHalfExtents, transform.forward, out hit, transform.rotation, RayCastLength))
            {
                // do something
            }
        }

        if (DoBoxCastAll)
        {
            RaycastHit[] hits = DebugPhysics.BoxCastAll(transform.position, BoxCastHalfExtents, transform.forward, transform.rotation, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                // do something
            }
        }

        if (DoBoxCastAllNonAlloc)
        {
            RaycastHit[] hits    = new RaycastHit[10];
            int          numHits = DebugPhysics.BoxCastNonAlloc(transform.position, BoxCastHalfExtents, transform.forward, hits, transform.rotation, RayCastLength);
            if (numHits > 0)
            {
                foreach (RaycastHit hit in hits)
                {
                    // do something
                }
            }
        }

        if (DoCapsuleCast)
        {
            if (DebugPhysics.CapsuleCast(transform.position, transform.position + point2, SphereCastRadius, transform.forward, RayCastLength))
            {
                // do something
            }
        }

        if (DoCapsuleCastHit)
        {
            RaycastHit hit;
            if (DebugPhysics.CapsuleCast(transform.position, transform.position + point2, SphereCastRadius, transform.forward, out hit, RayCastLength))
            {
                // do something
            }
        }

        if (DoCapsuleCastAll)
        {
            RaycastHit[] hits = DebugPhysics.CapsuleCastAll(transform.position, transform.position + point2, SphereCastRadius, transform.forward, RayCastLength);
            foreach (RaycastHit hit in hits)
            {
                // do something
            }
        }

        if (DoCapsuleCastNonAlloc)
        {
            RaycastHit[] hits    = new RaycastHit[10];
            int          numHits = DebugPhysics.CapsuleCastNonAlloc(transform.position, transform.position + point2, SphereCastRadius, transform.forward, hits, RayCastLength);
            if (numHits > 0)
            {
                foreach (RaycastHit hit in hits)
                {
                    // do something
                }
            }
        }


        // BoxCapsuleSphere Check
        if (DoBoxCheck)
        {
            if (DebugPhysics.CheckBox(transform.position, BoxCastHalfExtents, transform.rotation))
            {
            }
        }
        if (DoCapsuleCheck)
        {
            if (DebugPhysics.CheckCapsule(transform.position, transform.position + point2, SphereCastRadius))
            {
            }
        }
        if (DoSphereCheck)
        {
            if (DebugPhysics.CheckSphere(transform.position, SphereCastRadius))
            {
            }
        }

        // Overlaps
        if (DoBoxOverlap)
        {
            Collider[] colliders = DebugPhysics.OverlapBox(transform.position, BoxCastHalfExtents, transform.rotation);
            if (colliders.Length > 0)
            {
                // do something
            }
        }
        if (DoBoxOverlapNonAlloc)
        {
            Collider[] colliders = new Collider[8];
            DebugPhysics.OverlapBoxNonAlloc(transform.position, BoxCastHalfExtents, colliders, transform.rotation);
            foreach (Collider c in colliders)
            {
                // do something
            }
        }
        if (DoSphereOverlap)
        {
            Collider[] colliders = DebugPhysics.OverlapSphere(transform.position, SphereCastRadius);
            if (colliders.Length > 0)
            {
                // do something
            }
        }
        if (DoSphereOverlapNonAlloc)
        {
            Collider[] colliders = new Collider[8];
            DebugPhysics.OverlapSphereNonAlloc(transform.position, SphereCastRadius, colliders);
            foreach (Collider c in colliders)
            {
                // do something
            }
        }
        if (DoCapsuleOverlap)
        {
            Collider[] colliders = DebugPhysics.OverlapCapsule(transform.position, transform.position + point2, SphereCastRadius);
            if (colliders.Length > 0)
            {
                // do something
            }
        }
        if (DoCapsuleOverlapNonAlloc)
        {
            Collider[] colliders = new Collider[8];
            DebugPhysics.OverlapCapsuleNonAlloc(transform.position, transform.position + point2, SphereCastRadius, colliders);
            foreach (Collider c in colliders)
            {
                // do something
            }
        }
        if (ComputePenetration)
        {
            Vector3 penetrateDirection = Vector3.zero;
            float   penetrateDistance  = 0.0f;
            if (DebugPhysics.ComputePenetration(GetComponent <Collider>(), transform.position + point2, transform.rotation, penetrate, penetrate.transform.position, penetrate.transform.rotation, out penetrateDirection, out penetrateDistance))
            {
                // do something
            }
        }
    }
コード例 #3
0
 void Start()
 {
     current = this;
 }
コード例 #4
0
 void Awake()
 {
     current = this;
 }