docs.unity3d.com
    Show / Hide Table of Contents

    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
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    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
    ISpline.Closed

    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
    IReadOnlyCollection<T>.Count

    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
    IReadOnlyList<T>.Item[Int32]

    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
    ISpline.GetCurve(Int32)

    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
    ISpline.GetCurveInterpolation(Int32, Single)
    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
    ISpline.GetCurveLength(Int32)
    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
    GetLength()

    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
    IEnumerable<T>.GetEnumerator()

    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
    ISpline.GetLength()
    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
    GetCurveLength(Int32)

    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.

    Implements
    IEnumerable.GetEnumerator()

    Extension Methods

    SplineUtility.Evaluate<T>(T, Single, out float3, out float3, out float3)
    SplineUtility.EvaluatePosition<T>(T, Single)
    SplineUtility.EvaluateTangent<T>(T, Single)
    SplineUtility.EvaluateUpVector<T>(T, Single)
    SplineUtility.EvaluateAcceleration<T>(T, Single)
    SplineUtility.EvaluateCurvature<T>(T, Single)
    SplineUtility.EvaluateCurvatureCenter<T>(T, Single)
    SplineUtility.SplineToCurveT<T>(T, Single, out Single)
    SplineUtility.CurveToSplineT<T>(T, Single)
    SplineUtility.CalculateLength<T>(T, float4x4)
    SplineUtility.GetCurveCount<T>(T)
    SplineUtility.GetBounds<T>(T)
    SplineUtility.GetBounds<T>(T, float4x4)
    SplineUtility.GetPointAtLinearDistance<T>(T, Single, Single, out Single)
    SplineUtility.ConvertIndexUnit<T>(T, Single, PathIndexUnit)
    SplineUtility.ConvertIndexUnit<T>(T, Single, PathIndexUnit, PathIndexUnit)
    SplineUtility.PreviousIndex<T>(T, Int32)
    SplineUtility.NextIndex<T>(T, Int32)
    SplineUtility.Previous<T>(T, Int32)
    SplineUtility.Next<T>(T, Int32)
    SplineDataHandles.DataPointHandles<TSpline, TData>(TSpline, SplineData<TData>, Boolean)
    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