docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeSpline

    A readonly 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.

    Namespace: UnityEngine.Splines
    Syntax
    public struct NativeSpline : ISpline, IDisposable
    Remarks

    NativeSpline is compatible with the job system.

    Constructors

    NativeSpline(IList<BezierKnot>, Boolean, Allocator)

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(IList<BezierKnot> knots, bool closed, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    IList<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).

    Allocator allocator

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

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

    Create a new NativeSpline from a set of BezierKnot.

    Declaration
    public NativeSpline(IList<BezierKnot> knots, bool closed, float4x4 transform, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    IList<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.

    Properties

    Closed

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

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

    Item[Int32]

    Get the knot at index.

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

    The zero-based index of the knot.

    Property Value
    Type Description
    BezierKnot
    Implements
    ISpline.Item[Int32]

    KnotCount

    Return the number of knots.

    Declaration
    public int KnotCount { get; }
    Property Value
    Type Description
    Int32
    Implements
    ISpline.KnotCount

    Knots

    A NativeArray of BezierKnot that form this Spline.

    Declaration
    public 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()

    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)

    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)

    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()

    Extension Methods

    SplineUtility.EvaluatePosition<T>(T, Single)
    SplineUtility.EvaluateDirection<T>(T, Single)
    SplineUtility.EvaluateUpVector<T>(T, Single)
    SplineUtility.SplineToCurveInterpolation<T>(T, Single, out Single)
    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