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
Assembly: Unity.Splines.dll
Syntax
[Serializable]
public struct SplineRange : IEnumerable<int>, IEnumerable
Constructors
SplineRange(int, int)
Creates a new SplineRange from a start index and count.
Declaration
public SplineRange(int start, int count)
Parameters
Type | Name | Description |
---|---|---|
int | start | The inclusive first index of a range. |
int | 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(int, int, SliceDirection)
Creates a new SplineRange from a start index and count.
Declaration
public SplineRange(int start, int count, SliceDirection direction)
Parameters
Type | Name | Description |
---|---|---|
int | start | The inclusive first index of a range. |
int | 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 |
---|---|
int |
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 int End { get; }
Property Value
Type | Description |
---|---|
int |
this[int]
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 int this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the element to get or set. |
Property Value
Type | Description |
---|---|
int |
Start
The inclusive first index, starting at 0.
Declaration
public int Start { get; set; }
Property Value
Type | Description |
---|---|
int |
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<int> | An IEnumerator that is used to iterate the collection. |
ToString()
Returns a string summary of this range.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | Returns a string summary of this range. |