Assets/SplineTool/Scripts/CorgiSpline/Spline.cs
/// <summary>
/// Sets the Spline's Curve Type. 
/// If there are not a valid number of Points when turning a Linear spline into a Bezier spline, 
/// this function will append some more points, so be careful.
/// </summary>
/// <param name="newMode"></param>
Sets the Spline's Curve Type.
If there are not a valid number of Points when turning a Linear spline into a Bezier spline,
this function will append some more points, so be careful.
Sets the Spline ' s Curve Type . If there are not a valid number of Points when turning a Linear spline into a Bezier spline this function will append some more points so be careful .
public void SetSplineMode(SplineMode newMode)
        {
            if (Mode != newMode)
            {
                Mode = newMode;
                if (newMode == SplineMode.Bezier)
                {
                    var create_count = 0;
                    var point_mod = (Points.Length - 1) % 3;
                    if (point_mod == 0) create_count = 0;
                    else if (point_mod == 1) create_count = 2;
                    else if (point_mod == 2) create_count = 1;
                    if (create_count > 0)
                    {
                        var final_point = GetPoint(1f);
                        var final_forward = GetForward(1f);
                        var final_index = Points.Length;
                        ResizePointArray(Points.Length + create_count);
                        for (var i = final_index; i < Points.Length; ++i)
                        {
                            final_point.position += final_forward;
                            Points[i] = final_point;
                        }
#if UNITY_EDITOR
                        Debug.LogWarning($"Created {create_count} new points to ensure valid Bezier spline.");
#endif
                    }
                }
            }
        }
public void SetSplineMode ( SplineMode newMode ) { if ( Mode != newMode ) { Mode = newMode ; if ( newMode == SplineMode . Bezier ) { var create_count = 0 ; var point_mod = ( Points . Length - 1 ) % 3 ; if ( point_mod == 0 ) create_count = 0 ; else if ( point_mod == 1 ) create_count = 2 ; else if ( point_mod == 2 ) create_count = 1 ; if ( create_count > 0 ) { var final_point = GetPoint ( 1f ) ; var final_forward = GetForward ( 1f ) ; var final_index = Points . Length ; ResizePointArray ( Points . Length + create_count ) ; for ( var i = final_index ; i < Points . Length ; ++ i ) { final_point . position += final_forward ; Points [ i ] = final_point ; } if UNITY_EDITOR Debug . LogWarning ( $" Created  { create_count }  new points to ensure valid Bezier spline. " ) ; endif } } } }
Sets the Spline's Curve Type.
Sets the Spline ' s Curve Type .
// need to
newMode
SplineMode
None