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
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
KnotCount
Return the number of knots.
Declaration
public int KnotCount { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Implements
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
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
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. |