docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeSpline

    A read-only representation of Spline that is optimized for efficient access and queries. NativeSpline can be constructed with a spline and Transform. If a transform is applied, all values will be relative to the transformed knot positions.

    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 NativeSpline : ISpline, IReadOnlyList<BezierKnot>, IReadOnlyCollection<BezierKnot>, IEnumerable<BezierKnot>, IEnumerable, IDisposable
    Remarks

    NativeSpline is compatible with the job system.

    Constructors

    NativeSpline(IReadOnlyList<BezierKnot>, Boolean, float4x4, Allocator)

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(IReadOnlyList<BezierKnot> knots, bool closed, float4x4 transform, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    IReadOnlyList<BezierKnot> knots

    A collection of sequential BezierKnot forming the spline path.

    Boolean closed

    Whether the spline is open (has a start and end point) or closed (forms an unbroken loop).

    float4x4 transform

    Apply a transformation matrix to the control Knots.

    Allocator allocator

    The memory allocation method to use when reserving space for native arrays.

    NativeSpline(IReadOnlyList<BezierKnot>, IReadOnlyList<Int32>, Boolean, float4x4, Allocator)

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(IReadOnlyList<BezierKnot> knots, IReadOnlyList<int> splits, bool closed, float4x4 transform, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    IReadOnlyList<BezierKnot> knots

    A collection of sequential BezierKnot forming the spline path.

    IReadOnlyList<Int32> splits

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

    Boolean closed

    Whether the spline is open (has a start and end point) or closed (forms an unbroken loop).

    float4x4 transform

    Apply a transformation matrix to the control Knots.

    Allocator allocator

    The memory allocation method to use when reserving space for native arrays.

    NativeSpline(ISpline, Allocator)

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(ISpline spline, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    ISpline spline

    The ISpline object to convert to a NativeSpline.

    Allocator allocator

    The memory allocation method to use when reserving space for native arrays.

    NativeSpline(ISpline, float4x4, Allocator)

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(ISpline spline, float4x4 transform, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    ISpline spline

    The ISpline object to convert to a NativeSpline.

    float4x4 transform

    A transform matrix to be applied to the spline knots and tangents.

    Allocator allocator

    The memory allocation method to use when reserving space for native arrays.

    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.

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

    Curves

    A NativeArray of BezierCurve that form this Spline.

    Declaration
    public readonly NativeArray<BezierCurve> Curves { get; }
    Property Value
    Type Description
    NativeArray<BezierCurve>

    Returns a reference to the curves array.

    Item[Int32]

    Get the knot at index.

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

    The zero-based index of the knot.

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

    Knots

    A NativeArray of BezierKnot that form this Spline.

    Declaration
    public readonly NativeArray<BezierKnot> Knots { get; }
    Property Value
    Type Description
    NativeArray<BezierKnot>

    Returns a reference to the knots array.

    Methods

    Dispose()

    Release allocated resources.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    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)

    GetCurveLength(Int32)

    Get the length of a BezierCurve.

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

    The 0 based index of the curve to find length for.

    Returns
    Type Description
    Single

    The length of the bezier curve at index.

    Implements
    ISpline.GetCurveLength(Int32)

    GetEnumerator()

    Get 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. Note that this value is affected by the transform used to create this NativeSpline.

    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)
    SplineDataHandles.DataPointHandles<TSpline, TData>(TSpline, SplineData<TData>, Boolean, Int32)
    Back to top
    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