DrawArrow() public static method

Draws an arrow using Debug.Draw
public static DrawArrow ( Vector2 origin, Vector2 endpoint, Color color, float duration = 0.01f ) : void
origin UnityEngine.Vector2 Origin point in world space.
endpoint UnityEngine.Vector2 Endpoint in world space.
color UnityEngine.Color Color for Debug.Draw.
duration float Duration to show the arrow.
return void
Esempio n. 1
0
        private static void DrawLineAndHits(RaycastHit2D[] hits, Vector2 origin, Vector2 endpoint)
        {
            DrawHitsForRaycasts(hits);

            Color drawColor = RaycastHitsContainHit(hits) ? HitCastColor : CastColor;

            DebugUtility.DrawArrow(origin, endpoint, drawColor);
        }
Esempio n. 2
0
        private static void DrawCircleCastAndHits(
            RaycastHit2D[] hits,
            Vector2 origin,
            float radius,
            Vector2 direction,
            float distance = Mathf.Infinity)
        {
            // Nothing to draw with a 0 radius or 0 distance
            if (Mathf.Approximately(radius, 0.0f) || Mathf.Approximately(distance, 0.0f))
            {
                return;
            }

            // Just in case direction isn't normalized, do it now
            if (!Mathf.Approximately(direction.sqrMagnitude, 1.0f))
            {
                direction.Normalize();
            }

            DrawHitsForCirclecast(hits, radius);

            Color drawColor = RaycastHitsContainHit(hits) ? HitCastColor : CastColor;

            // Draw origin and end circles
            DebugUtility.DrawCircle(origin, radius, drawColor);
            Vector2 endCirclePosition = origin + (direction * distance);

            DebugUtility.DrawCircle(endCirclePosition, radius, drawColor);

            // Draw edges
            Vector2 radiusSegment    = direction * radius;
            Vector2 orthoganalRadius = new Vector2(radiusSegment.y, -radiusSegment.x);

            DebugUtility.DrawArrow(origin + orthoganalRadius, endCirclePosition + orthoganalRadius, drawColor);
            DebugUtility.DrawArrow(origin - orthoganalRadius, endCirclePosition - orthoganalRadius, drawColor);
        }