docs.unity3d.com
Search Results for

    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.

    If performance is a critical requirement, create a new Spline or NativeSpline from your SplinePath<T>. Note that you might pass a SplinePath<T> to constructors for both Spline and NativeSpline.

    Inheritance
    object
    SplinePath<T>
    SplinePath
    Implements
    ISpline
    IReadOnlyList<BezierKnot>
    IReadOnlyCollection<BezierKnot>
    IEnumerable<BezierKnot>
    IEnumerable
    IHasEmptyCurves
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Splines
    Assembly: Unity.Splines.dll
    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.

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    Properties

    Closed

    SplinePathRef does not support Closed splines.

    Declaration
    public bool Closed { get; }
    Property Value
    Type Description
    bool
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    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(int) to access curves rather than construct the curve yourself.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    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<int>
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    this[int]

    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
    int index

    The zero-based index of the element to get.

    Property Value
    Type Description
    BezierKnot
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    this[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
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    Slices

    The ISpline splines that make up this path.

    Declaration
    public IReadOnlyList<T> Slices { get; set; }
    Property Value
    Type Description
    IReadOnlyList<T>
    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    Methods

    GetCurve(int)

    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
    int 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.

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    GetCurveInterpolation(int, float)

    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
    int curveIndex

    The zero-based index of the curve.

    float curveDistance

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

    Returns
    Type Description
    float

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

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    GetCurveLength(int)

    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
    int index

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

    Returns
    Type Description
    float

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

    See Also
    GetLength()

    GetCurveUpVector(int, float)

    Return the up vector for a t ratio on the curve.

    Declaration
    public float3 GetCurveUpVector(int index, float t)
    Parameters
    Type Name Description
    int index

    The index of the curve for which the length needs to be retrieved.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    Returns the up vector at the t ratio of the curve of index 'index'.

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    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.

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    GetLength()

    Return the sum of all curve lengths, accounting for Closed state.

    Declaration
    public float GetLength()
    Returns
    Type Description
    float

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

    See Also
    SplineRange
    KnotLinkCollection
    SplineKnotIndex

    Implements

    ISpline
    IReadOnlyList<T>
    IReadOnlyCollection<T>
    IEnumerable<T>
    IEnumerable
    IHasEmptyCurves

    Extension Methods

    SplineUtility.CalculateLength<T>(T, float4x4)
    SplineUtility.CalculateUpVector<T>(T, float)
    SplineUtility.ConvertIndexUnit<T>(T, float, PathIndexUnit)
    SplineUtility.ConvertIndexUnit<T>(T, float, PathIndexUnit, PathIndexUnit)
    SplineUtility.CurveToSplineT<T>(T, float)
    SplineUtility.EvaluateAcceleration<T>(T, float)
    SplineUtility.EvaluateCurvatureCenter<T>(T, float)
    SplineUtility.EvaluateCurvature<T>(T, float)
    SplineUtility.EvaluatePosition<T>(T, float)
    SplineUtility.EvaluateTangent<T>(T, float)
    SplineUtility.EvaluateUpVector<T>(T, float)
    SplineUtility.Evaluate<T>(T, float, out float3, out float3, out float3)
    SplineUtility.GetBounds<T>(T)
    SplineUtility.GetBounds<T>(T, float4x4)
    SplineUtility.GetCurveCount<T>(T)
    SplineUtility.GetPointAtLinearDistance<T>(T, float, float, out float)
    SplineUtility.NextIndex<T>(T, int)
    SplineUtility.Next<T>(T, int)
    SplineUtility.PreviousIndex<T>(T, int)
    SplineUtility.Previous<T>(T, int)
    SplineUtility.SplineToCurveT<T>(T, float, out float)

    See Also

    SplineRange
    KnotLinkCollection
    SplineKnotIndex
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)