The following code does not work as expected
var splineContainer = GetComponent<SplineContainer>(); // Assume this container already has some splines
splineContainer.Splines = null; // Should clear all existing splines
splineContainer.AddSpline(new Spline()); // Expect to have one spline now
The reason is that SplineContainer.set_Splines sets m_Splines to Array.Empty, but does not clear m_ReadOnlySplines, which SplineUtility.AddSpline depends on.
The following code does not work as expected
The reason is that
SplineContainer.set_Splinessetsm_SplinestoArray.Empty, but does not clearm_ReadOnlySplines, whichSplineUtility.AddSplinedepends on.