Struct SplineSlice<T>
SplineSlice represents a partial or complete range of curves from another Spline. A SplineSlice<T> by itself does not store any BezierKnots. It stores a reference to a separate Spline, then retrieves knots by iterating the SplineRange. Use SplineSlice<T> in conjunction with SplinePath to create seamless paths from discrete Spline segments.
Inherited Members
Namespace: UnityEngine.Splines
Syntax
public struct SplineSlice<T> : ISpline, IReadOnlyList<BezierKnot>, IReadOnlyCollection<BezierKnot>, IEnumerable<BezierKnot>, IEnumerable where T : ISpline
Type Parameters
Name | Description |
---|---|
T | The type of spline that this slice represents. |
Remarks
Iterating a SplineSlice<T> is not as efficient as iterating a Spline or NativeSpline because it does not cache any information. Where performance is a concern, create a new Spline or NativeSpline from the SplineSlice<T>.
Constructors
SplineSlice(T, SplineRange)
Constructor for a new SplineSlice.
Declaration
public SplineSlice(T spline, SplineRange range)
Parameters
Type | Name | Description |
---|---|---|
T | spline | The Spline that this Slice will read BezierKnot and BezierCurve data from. |
SplineRange | range | The start index and count of knot indices that compose this slice. |
SplineSlice(T, SplineRange, float4x4)
Constructor for a new SplineSlice.
Declaration
public SplineSlice(T spline, SplineRange range, float4x4 transform)
Parameters
Type | Name | Description |
---|---|---|
T | spline | The Spline that this Slice will read BezierKnot and BezierCurve data from. |
SplineRange | range | The start index and count of knot indices that compose this slice. |
float4x4 | transform | A transform matrix to be applied to the spline knots and tangents. |
Fields
Range
An inclusive start index, number of indices, and direction to iterate.
Declaration
public SplineRange Range
Field Value
Type | Description |
---|---|
SplineRange |
Spline
The Spline that this Slice will read BezierKnot and BezierCurve data from. A SplineSlice<T> by itself does not store any BezierKnots. Instead, it references a partial or complete range of existing Splines.
Declaration
public T Spline
Field Value
Type | Description |
---|---|
T |
Transform
A transform matrix to be applied to the spline knots and tangents.
Declaration
public float4x4 Transform
Field Value
Type | Description |
---|---|
float4x4 |
Properties
Closed
Whether the spline is open (has a start and end point) or closed (forms an unbroken loop).
Declaration
public readonly bool Closed { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Count
Return the number of knots in this branch. This function clamps the Range to the Count of the the referenced Spline.
Declaration
public readonly int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
Item[Int32]
Get a BezierKnot at the zero-based index of this SplineSlice<T>.
Declaration
public readonly BezierKnot this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index to get. |
Property Value
Type | Description |
---|---|
BezierKnot |
Implements
Methods
GetCurve(Int32)
Get a BezierCurve from a knot index.
Declaration
public BezierCurve GetCurve(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The knot index that serves as 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)
Return the normalized interpolation (t) corresponding to a distance on a BezierCurve.
Declaration
public float GetCurveInterpolation(int curveIndex, float curveDistance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | curveIndex | The zero-based index of the curve. |
Single | curveDistance | The curve-relative distance to convert to an interpolation ratio (also referred to as 't'). |
Returns
Type | Description |
---|---|
Single | The normalized interpolation ratio associated to distance on the designated curve. |
Implements
Remarks
It is inefficient to call this method frequently, as it will calculate the interpolation lookup table every time it is invoked. In cases where performance is critical, create a new Spline or NativeSpline instead. Note that you may pass a SplineSlice<T> to constructors for both Spline and NativeSpline.
GetCurveLength(Int32)
Return the length of a curve.
Declaration
public float GetCurveLength(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the curve for which the length needs to be retrieved. |
Returns
Type | Description |
---|---|
Single | Returns the length of the curve of index 'index' in the spline. |
Implements
Remarks
It is inefficient to call this method frequently, as it will calculate the length of the curve every time it is invoked. In cases where performance is critical, create a new Spline or NativeSpline instead. Note that you may pass a SplineSlice<T> to constructors for both Spline and NativeSpline.
See Also
GetEnumerator()
Get an enumerator that iterates through the BezierKnot collection. Note that this will either increment or decrement indices depending on the value of the Direction.
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.
Declaration
public float GetLength()
Returns
Type | Description |
---|---|
Single | Returns the sum length of all curves composing this spline. |
Implements
Remarks
It is inefficient to call this method frequently, as it will calculate the length of all curves every time it is invoked. In cases where performance is critical, create a new Spline or NativeSpline instead. Note that you may pass a SplineSlice<T> to constructors for both Spline and NativeSpline.
See Also
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Gets an enumerator that iterates through the BezierKnot collection. It either increments or decrements indices depending on the value of the Direction.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | Returns an IEnumerator that is used to iterate the BezierKnot collection. |