// Copyright (c) Pixel Crushers. All rights reserved. using UnityEngine; namespace PixelCrushers { /// /// Provides more drawing routines for gizmos. /// public static class MoreGizmos { /// /// Draws an arrow, which is a ray with an arrowhead at the end. /// /// /// Start of the ray. /// /// /// Direction and length the ray extends. /// /// /// Length of the arrowhead that extends from the end the ray. /// /// /// Angle of the arrowhead in degrees. /// public static void DrawArrow(Vector3 from, Vector3 direction, float arrowheadLength = 0.2f, float arrowheadAngle = 30f) { if (Mathf.Approximately(direction.magnitude, 0)) return; Vector3 right = Quaternion.LookRotation(direction) * Quaternion.Euler(0, 180f + arrowheadAngle, 0) * Vector3.forward; Vector3 left = Quaternion.LookRotation(direction) * Quaternion.Euler(0, 180f - arrowheadAngle, 0) * Vector3.forward; Gizmos.DrawRay(from, direction); Gizmos.DrawRay(from + direction, right * arrowheadLength); Gizmos.DrawRay(from + direction, left * arrowheadLength); } } }