docs.unity3d.com
    Show / Hide Table of Contents

    Class SplinePath<T>

    The SplinePath type is an implementation of ISpline that is composed of multiple sections of other splines (see SplineSlice<T>). This is useful when you want to evaluate a path that follows multiple splines, typically in the case where splines share linked knots.

    Inheritance
    Object
    SplinePath<T>
    SplinePath
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.Splines
    Syntax
    public class SplinePath<T> : ISpline, IReadOnlyList<BezierKnot>, IReadOnlyCollection<BezierKnot>, IEnumerable<BezierKnot>, IEnumerable, IHasEmptyCurves where T : ISpline
    Type Parameters
    Name Description
    T

    The type of spline to create a path with.

    Constructors

    SplinePath(IEnumerable<T>)

    Create a new SplinePath<T> from a collection of ISpline.

    Declaration
    public SplinePath(IEnumerable<T> slices)
    Parameters
    Type Name Description
    IEnumerable<T> slices

    A collection of ISpline.

    Properties

    Closed

    UnityEngine.Splines.SplinePathRef does not support Closed splines.

    Declaration
    public bool Closed { get; }
    Property Value
    Type Description
    Boolean
    Implements
    ISpline.Closed

    Count

    Returns the number of knots. Note that there are duplicate knots where two ISpline meet. In addition, each closed ISpline have their first knot duplicated. Use GetCurve(Int32) to access curves rather than construct the curve yourself.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32
    Implements
    IReadOnlyCollection<T>.Count

    EmptyCurves

    A collection of knot indices that should be considered degenerate curves for the purpose of creating a non-interpolated gap between curves.

    Declaration
    public IReadOnlyList<int> EmptyCurves { get; }
    Property Value
    Type Description
    IReadOnlyList<Int32>
    Implements
    IHasEmptyCurves.EmptyCurves

    Item[Int32]

    Gets the knot at index. If the ISpline section that contains this knot has a SplineRange with Backward, the in and out tangents are reversed.

    Declaration
    public BezierKnot this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index

    The zero-based index of the element to get.

    Property Value
    Type Description
    BezierKnot
    Implements
    IReadOnlyList<T>.Item[Int32]

    Item[SplineKnotIndex]

    Gets the knot at index. If the ISpline segment that contains this knot has a SplineRange with Backward, the in and out tangents are reversed.

    Declaration
    public BezierKnot this[SplineKnotIndex index] { get; }
    Parameters
    Type Name Description
    SplineKnotIndex index

    The zero-based index of the slice and knot to get.

    Property Value
    Type Description
    BezierKnot

    Slices

    The ISpline splines that make up this path.

    Declaration
    public IReadOnlyList<T> Slices { get; set; }
    Property Value
    Type Description
    IReadOnlyList<T>

    Methods

    GetCurve(Int32)

    Gets a BezierCurve from a knot index. This function returns degenerate (0 length) curves at the overlap points between each ISpline.

    Declaration
    public BezierCurve GetCurve(int knot)
    Parameters
    Type Name Description
    Int32 knot

    The knot index that is 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)

    Returns the interpolation ratio (0 to 1) that corresponds to a distance on a BezierCurve. The distance is relative to the curve.

    Declaration
    public float GetCurveInterpolation(int curveIndex, float curveDistance)
    Parameters
    Type Name Description
    Int32 curveIndex

    The zero-based index of the curve.

    Single curveDistance

    The distance measured from the knot at curveIndex to convert to a normalized interpolation ratio.

    Returns
    Type Description
    Single

    The normalized interpolation ratio that matches the distance on the designated curve.

    Implements
    ISpline.GetCurveInterpolation(Int32, Single)

    GetCurveLength(Int32)

    Returns the length of a curve. This function returns 0 length for knot indices where ISpline segments overlap.

    Declaration
    public float GetCurveLength(int index)
    Parameters
    Type Name Description
    Int32 index

    The index of the curve that the length is retrieved from.

    Returns
    Type Description
    Single

    Returns the length of the curve of index 'index' in the spline.

    Implements
    ISpline.GetCurveLength(Int32)
    See Also
    GetLength()

    GetEnumerator()

    Gets an enumerator that iterates through the BezierKnot collection.

    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, accounting for Closed state.

    Declaration
    public float GetLength()
    Returns
    Type Description
    Single

    Returns the sum length of all curves composing this spline, accounting for closed state.

    Implements
    ISpline.GetLength()

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Gets an enumerator that iterates through the BezierKnot collection.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    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)

    See Also

    SplineRange
    KnotLinkCollection
    SplineKnotIndex
    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