/// <summary> /// Renders a Curve to the Scene View. Should only be called from OnSceneGUI. /// </summary> /// <param name="curve">Curve to render.</param> private void DisplayCurveInSceneView(BezierCurve curve) { Vector3 lineStart = transform.TransformPoint(curve.FindPointAlongCurve(0)); UnityEditor.Handles.color = Color.white; for (int i = 1; i <= lineSteps; i++) { Vector3 lineEnd = transform.TransformPoint(curve.FindPointAlongCurve((float)i / lineSteps)); UnityEditor.Handles.DrawLine(lineStart, lineEnd); lineStart = lineEnd; } }
/// <summary> /// Gets the point on the spline at a specified distance from its start point. /// </summary> /// <param name="dist">Distance from spline's start point.</param> /// <returns>Returns the point along spline at dist.</returns> public Vector3 GetPointOnSplineByDistance(float dist) { float t = 0; dist = dist % GetTotalLength(); BezierCurve seg = GetCurveFromDistance(dist, out t); return(transform.TransformPoint(seg.FindPointAlongCurve(t))); }