Work with curves and paths. Use the Splines package to generate objects and behaviors along paths, create trajectories, and draw shapes. 📦 [Mirrored from UPM, not affiliated with Unity Technologies.]
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_Splines
setsm_Splines
toArray.Empty
, but does not clearm_ReadOnlySplines
, whichSplineUtility.AddSpline
depends on.