public static void GizmosDrawLineInterpolated(LineBase source, LineRendererBase renderer) { Vector3 firstPos = source.GetPoint(0f); Vector3 lastPos = firstPos; Color gColor = renderer.GetColor(0); gColor.a = 0.5f; Gizmos.color = gColor; Gizmos.DrawSphere(firstPos, renderer.GetWidth(0) / 2); for (int i = 1; i <= renderer.NumLineSteps; i++) { float normalizedLength = (1f / (renderer.NumLineSteps)) * i; Vector3 currentPos = source.GetPoint(normalizedLength); gColor = renderer.GetColor(normalizedLength); gColor.a = gColor.a * 0.5f; Gizmos.color = gColor; Gizmos.DrawLine(lastPos, currentPos); Gizmos.DrawSphere(currentPos, renderer.GetWidth(normalizedLength) / 2); lastPos = currentPos; } if (source.Loops) { Gizmos.DrawLine(lastPos, firstPos); } }
public static void GizmosDrawLineRenderer(LineBase source, LineRendererBase renderer) { switch (renderer.StepMode) { case StepModeEnum.FromSource: GizmosDrawLineFromSource(source, renderer); break; case StepModeEnum.Interpolated: GizmosDrawLineInterpolated(source, renderer); break; } }
protected virtual void OnDrawGizmos() { // Show gizmos if this object is not selected // (SceneGUI will display it otherwise) if (Application.isPlaying) { return; } if (UnityEditor.Selection.activeGameObject == this.gameObject) { return; } // Only draw a gizmo if we don't have a line renderer LineRendererBase lineRenderer = gameObject.GetComponent <LineRendererBase>(); if (lineRenderer != null) { return; } Vector3 firstPos = GetPoint(0f); Vector3 lastPos = firstPos; Gizmos.color = Color.Lerp(LineBaseEditor.DefaultDisplayLineColor, Color.clear, 0.25f); int numSteps = 16; for (int i = 1; i < numSteps; i++) { float normalizedLength = (1f / (numSteps - 1)) * i; Vector3 currentPos = GetPoint(normalizedLength); Gizmos.DrawLine(lastPos, currentPos); lastPos = currentPos; } if (Loops) { Gizmos.DrawLine(lastPos, firstPos); } }
protected override void OnDrawGizmos() { // Show gizmos if this object is not selected // (SceneGUI will display it otherwise) if (Application.isPlaying) { return; } if (UnityEditor.Selection.activeGameObject == this.gameObject) { return; } // Only draw a gizmo if we don't have a line renderer LineRendererBase lr = gameObject.GetComponent <LineRendererBase>(); if (lr != null) { return; } Vector3 firstPos = GetPoint(0); Vector3 lastPos = firstPos; Gizmos.color = Color.Lerp(LineBaseEditor.DefaultDisplayLineColor, Color.clear, 0.25f); for (int i = 1; i < NumPoints; i++) { Vector3 currentPos = GetPoint(i); Gizmos.DrawLine(lastPos, currentPos); lastPos = currentPos; } Gizmos.DrawLine(lastPos, firstPos); }