Struct SplineRange
Describes a subset of knot indices in a Spline. The range might iterate in either the forward or backward direction.
Inherited Members
Namespace: UnityEngine.Splines
Syntax
[Serializable]
public struct SplineRange : IEnumerable<int>, IEnumerable
Constructors
SplineRange(Int32, Int32)
Creates a new SplineRange from a start index and count.
Declaration
public SplineRange(int start, int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | start | The inclusive first index of a range. |
Int32 | count | The number of elements this range encompasses. This value might be negative, which is shorthand to call the constructor with an explicit SliceDirection parameter. |
SplineRange(Int32, Int32, SliceDirection)
Creates a new SplineRange from a start index and count.
Declaration
public SplineRange(int start, int count, SliceDirection direction)
Parameters
Type | Name | Description |
---|---|---|
Int32 | start | The inclusive first index of a range. |
Int32 | count | The number of elements this range encompasses. |
SliceDirection | direction | Whether when iterating this range it is incrementing from start to start + count, or decrementing from start to start - count. |
Properties
Count
Returns the number of indices.
Declaration
public int Count { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Direction
The direction that this range interpolates. Forward increments the knot index when it iterates, whereas Backward decrements this index.
Declaration
public SliceDirection Direction { get; set; }
Property Value
Type | Description |
---|---|
SliceDirection |
End
The inclusive end index of this range.
Declaration
public readonly int End { get; }
Property Value
Type | Description |
---|---|
Int32 |
Item[Int32]
Get or set the Spline knot index at an index index
.
This indexer allows you to write a for loop to iterate through a range without needing to know in which
direction the range is iterating.
// Create a new range into an existing Spline starting at knot 5, and interpolating the span of 3 knots.
// range[0,1,2] will map to { 6, 5, 4 } respectively.
var range = new SplineRange(6, 3, SplineDirection.Backward);
Declaration
public readonly int this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the element to get or set. |
Property Value
Type | Description |
---|---|
Int32 |
Start
The inclusive first index, starting at 0.
Declaration
public int Start { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
GetEnumerator()
Get an enumerator that iterates through the index collection. Note that this will either increment or decrement indices depending on the value of the Direction property.
Declaration
public IEnumerator<int> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<Int32> | An IEnumerator that is used to iterate the collection. |
Implements
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Gets an enumerator that iterates through the index collection. It either increments or decrements indices depending on the value of the Direction property.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | Returns an IEnumerator that is used to iterate the collection. |