Class SplinePath<T>
The SplinePath type is an implementation of ISpline that is composed of multiple sections of other splines (see SplineSlice<T>). This is useful when you want to evaluate a path that follows multiple splines, typically in the case where splines share linked knots.
If performance is a critical requirement, create a new Spline or NativeSpline from your SplinePath<T>. Note that you might pass a SplinePath<T> to constructors for both Spline and NativeSpline.
Implements
Inherited Members
Namespace: UnityEngine.Splines
Assembly: Unity.Splines.dll
Syntax
public class SplinePath<T> : ISpline, IReadOnlyList<BezierKnot>, IReadOnlyCollection<BezierKnot>, IEnumerable<BezierKnot>, IEnumerable, IHasEmptyCurves where T : ISpline
Type Parameters
| Name | Description |
|---|---|
| T | The type of spline to create a path with. |
Constructors
SplinePath(IEnumerable<T>)
Create a new SplinePath<T> from a collection of ISpline.
Declaration
public SplinePath(IEnumerable<T> slices)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | slices | A collection of ISpline. |
See Also
Properties
Closed
SplinePathRef does not support Closed splines.
Declaration
public bool Closed { get; }
Property Value
| Type | Description |
|---|---|
| bool |
See Also
Count
Returns the number of knots. Note that there are duplicate knots where two ISpline meet. In addition, each closed ISpline have their first knot duplicated. Use GetCurve(int) to access curves rather than construct the curve yourself.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
See Also
EmptyCurves
A collection of knot indices that should be considered degenerate curves for the purpose of creating a non-interpolated gap between curves.
Declaration
public IReadOnlyList<int> EmptyCurves { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<int> |
See Also
this[int]
Gets the knot at index. If the ISpline section that contains this
knot has a SplineRange with Backward, the in and out tangents
are reversed.
Declaration
public BezierKnot this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the element to get. |
Property Value
| Type | Description |
|---|---|
| BezierKnot |
See Also
this[SplineKnotIndex]
Gets the knot at index. If the ISpline segment that contains this
knot has a SplineRange with Backward, the in and out tangents
are reversed.
Declaration
public BezierKnot this[SplineKnotIndex index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| SplineKnotIndex | index | The zero-based index of the slice and knot to get. |
Property Value
| Type | Description |
|---|---|
| BezierKnot |
See Also
Slices
The ISpline splines that make up this path.
Declaration
public IReadOnlyList<T> Slices { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<T> |
See Also
Methods
GetCurve(int)
Gets a BezierCurve from a knot index. This function returns degenerate (0 length) curves at the overlap points between each ISpline.
Declaration
public BezierCurve GetCurve(int knot)
Parameters
| Type | Name | Description |
|---|---|---|
| int | knot | The knot index that is the first control point for this curve. |
Returns
| Type | Description |
|---|---|
| BezierCurve | A BezierCurve formed by the knot at index and the next knot. |
See Also
GetCurveInterpolation(int, float)
Returns the interpolation ratio (0 to 1) that corresponds to a distance on a BezierCurve. The distance is relative to the curve.
Declaration
public float GetCurveInterpolation(int curveIndex, float curveDistance)
Parameters
| Type | Name | Description |
|---|---|---|
| int | curveIndex | The zero-based index of the curve. |
| float | curveDistance | The distance measured from the knot at curveIndex to convert to a normalized interpolation ratio. |
Returns
| Type | Description |
|---|---|
| float | The normalized interpolation ratio that matches the distance on the designated curve. |
See Also
GetCurveLength(int)
Returns the length of a curve. This function returns 0 length for knot indices where ISpline segments overlap.
Declaration
public float GetCurveLength(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the curve that the length is retrieved from. |
Returns
| Type | Description |
|---|---|
| float | Returns the length of the curve of index 'index' in the spline. |
See Also
GetCurveUpVector(int, float)
Return the up vector for a t ratio on the curve.
Declaration
public float3 GetCurveUpVector(int index, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the curve for which the length needs to be retrieved. |
| float | t | A value between 0 and 1 representing the ratio along the curve. |
Returns
| Type | Description |
|---|---|
| float3 | Returns the up vector at the t ratio of the curve of index 'index'. |
See Also
GetEnumerator()
Gets an enumerator that iterates through the BezierKnot collection.
Declaration
public IEnumerator<BezierKnot> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<BezierKnot> | An IEnumerator that is used to iterate the BezierKnot collection. |
See Also
GetLength()
Return the sum of all curve lengths, accounting for Closed state.
Declaration
public float GetLength()
Returns
| Type | Description |
|---|---|
| float | Returns the sum length of all curves composing this spline, accounting for closed state. |