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.
Inherited Members
Namespace: UnityEngine.Splines
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. |
Properties
Closed
UnityEngine.Splines.SplinePathRef does not support Closed splines.
Declaration
public bool Closed { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Implements
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(Int32) to access curves rather than construct the curve yourself.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Implements
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<Int32> |
Implements
Item[Int32]
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 |
|---|---|---|
| Int32 | index | The zero-based index of the element to get. |
Property Value
| Type | Description |
|---|---|
| BezierKnot |
Implements
Item[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 |
Slices
The ISpline splines that make up this path.
Declaration
public IReadOnlyList<T> Slices { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<T> |
Methods
GetCurve(Int32)
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 |
|---|---|---|
| Int32 | 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. |
Implements
GetCurveInterpolation(Int32, Single)
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 |
|---|---|---|
| Int32 | curveIndex | The zero-based index of the curve. |
| Single | curveDistance | The distance measured from the knot at curveIndex to convert to a normalized interpolation ratio. |
Returns
| Type | Description |
|---|---|
| Single | The normalized interpolation ratio that matches the distance on the designated curve. |
Implements
GetCurveLength(Int32)
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 |
|---|---|---|
| Int32 | index | The index of the curve that the length is retrieved from. |
Returns
| Type | Description |
|---|---|
| Single | Returns the length of the curve of index 'index' in the spline. |
Implements
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. |
Implements
GetLength()
Return the sum of all curve lengths, accounting for Closed state.
Declaration
public float GetLength()
Returns
| Type | Description |
|---|---|
| Single | Returns the sum length of all curves composing this spline, accounting for closed state. |
Implements
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Gets an enumerator that iterates through the BezierKnot collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator that is used to iterate the BezierKnot collection. |