コード例 #1
0
    public void DebugDrawBounds(Color colour, bool drawPhysicsEntity = true, bool bottomOnly = false, float duration = 15)
    {
        if (drawPhysicsEntity)
        {
            physicsEntity.DebugDrawRayCastOrigins(duration);
        }
        BoxCollider2D collider    = GetComponentInChildren <BoxCollider2D>();
        float         width       = collider.size.x;
        float         height      = collider.size.y;
        Vector2       bottomLeft  = (Vector2)transform.position + new Vector2(-width / 2, -height / 2);
        Vector2       bottomRight = (Vector2)transform.position + new Vector2(width / 2, -height / 2);

        Debug.DrawLine(bottomLeft, bottomRight, colour, duration);
        if (!bottomOnly)
        {
            Vector2 topLeft  = (Vector2)transform.position + new Vector2(-width / 2, height / 2);
            Vector2 topRight = (Vector2)transform.position + new Vector2(width / 2, height / 2);
            Debug.DrawLine(topLeft, topRight, colour, duration);
            Debug.DrawLine(topLeft, bottomLeft, colour, duration);
            Debug.DrawLine(bottomRight, topRight, colour, duration);
        }
    }