Esempio n. 1
0
        public static void Visualize(RaycastHit2D hit, Vector2 rayOrigin, RaycastHitColorAssigner rayColorAssigner = null, RaycastHitColorAssigner normalColorAssigner = null, float?visibilityDuration = null, params LineOptions[] options)
        {
            Vector2 p1 = rayOrigin;
            Vector2 p2;
            Color   rayColor;
            Color   normalColor = normalColorAssigner != null?normalColorAssigner(hit) : Color.yellow;

            float duration = visibilityDuration != null ? visibilityDuration.Value : 0f;

            if (hit.collider != null)
            {
                p2       = hit.point;
                rayColor = rayColorAssigner != null?rayColorAssigner(hit) : Color.red;

                Debug.DrawLine(hit.point, hit.point + hit.normal, normalColor, duration);
            }
            else
            {
                p2       = rayOrigin + hit.distance * hit.point;
                rayColor = rayColorAssigner != null?rayColorAssigner(hit) : Color.green;
            }

            if (ArrayOps.Contains(options, LineOptions.Dashed))
            {
                DrawDashedLine(p1, p2, .1f, rayColor, duration);
            }
            else
            {
                DrawLine(p1, p2, rayColor, duration);
            }
        }
Esempio n. 2
0
 static void HandleDrawLine(Vector3 start, Vector3 end, Color?color = null, float?duration = null, params LineOptions[] options)
 {
     if (ArrayOps.Contains(options, LineOptions.Dashed))
     {
         DrawDashedLine(start, end, .1f, color, duration);
     }
     else
     {
         DrawLine(start, end, color, duration);
     }
 }