docs.unity3d.com
    Show / Hide Table of Contents

    Struct SplineRange

    Describes a subset of knot indices in a Spline. The range might iterate in either the forward or backward direction.

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    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
    IEnumerable<T>.GetEnumerator()

    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.

    Implements
    IEnumerable.GetEnumerator()
    In This Article
    • Constructors
      • SplineRange(Int32, Int32)
      • SplineRange(Int32, Int32, SliceDirection)
    • Properties
      • Count
      • Direction
      • End
      • Item[Int32]
      • Start
    • Methods
      • GetEnumerator()
    • Explicit Interface Implementations
      • IEnumerable.GetEnumerator()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023