Class SplineContainer
A Component that holds a Spline object.
Inherited Members
Namespace: UnityEngine.Splines
Syntax
[AddComponentMenu("Splines/Spline")]
[ExecuteInEditMode]
public sealed class SplineContainer : MonoBehaviour, ISplineContainer, ISerializationCallbackReceiver
Properties
KnotLinkCollection
A collection of all linked knots. Linked knots can be on different splines. However, knots can only link to other knots within the same container. This collection is used to maintain the validity of the links when operations such as knot insertions or removals are performed on the splines.
Declaration
public KnotLinkCollection KnotLinkCollection { get; }
Property Value
Type | Description |
---|---|
KnotLinkCollection |
Implements
Spline
The main Spline attached to this component.
Declaration
public Spline Spline { get; set; }
Property Value
Type | Description |
---|---|
Spline |
Splines
The list of all splines attached to that container.
Declaration
public IReadOnlyList<Spline> Splines { get; set; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Spline> |
Implements
Methods
CalculateLength()
Calculate the length of Spline in world space.
Declaration
public float CalculateLength()
Returns
Type | Description |
---|---|
Single | The length of Spline in world space |
CalculateLength(Int32)
Calculates the length of Splines[splineIndex]
in world space.
Declaration
public float CalculateLength(int splineIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the spline to evaluate. |
Returns
Type | Description |
---|---|
Single | The length of |
Evaluate(Int32, Single, out float3, out float3, out float3)
Computes the interpolated position, direction and upDirection at ratio t for the spline at index splineIndex
. Calling this method to get the
3 vectors is faster than calling independently EvaluateSplinePosition, EvaluateSplineTangent and EvaluateSplineUpVector
for the same time t as it reduces some redundant computation.
Declaration
public bool Evaluate(int splineIndex, float t, out float3 position, out float3 tangent, out float3 upVector)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the spline to evaluate. |
Single | t | A value between 0 and 1 that represents the ratio along the curve. |
float3 | position | The output variable for the float3 position at t. |
float3 | tangent | The output variable for the float3 tangent at t. |
float3 | upVector | The output variable for the float3 up direction at t. |
Returns
Type | Description |
---|---|
Boolean | True if a valid set of output variables is computed and false otherwise. |
Evaluate(Single, out float3, out float3, out float3)
Computes interpolated position, direction and upDirection at ratio t. Calling this method to get the 3 vectors is faster than calling independently EvaluateSplinePosition, EvaluateSplineTangent and EvaluateSplineUpVector for the same time t as it reduces some redundant computation.
Declaration
public bool Evaluate(float t, out float3 position, out float3 tangent, out float3 upVector)
Parameters
Type | Name | Description |
---|---|---|
Single | t | A value between 0 and 1 representing the ratio along the curve. |
float3 | position | The output variable for the float3 position at t. |
float3 | tangent | The output variable for the float3 tangent at t. |
float3 | upVector | The output variable for the float3 up direction at t. |
Returns
Type | Description |
---|---|
Boolean | Boolean value, true if a valid set of output variables as been computed. |
Evaluate<T>(T, Single, out float3, out float3, out float3)
Gets the interpolated position, direction, and upDirection at ratio t for a spline. This method gets the three
vectors faster than EvaluateSplinePosition, EvaluateSplineTangent and EvaluateSplineUpVector for the same
time t, because it reduces some redundant computation.
Declaration
public bool Evaluate<T>(T spline, float t, out float3 position, out float3 tangent, out float3 upVector)
where T : ISpline
Parameters
Type | Name | Description |
---|---|---|
T | spline | The spline to evaluate. |
Single | t | A value between 0 and 1 that represents the ratio along the curve. |
float3 | position | The output variable for the float3 position at t. |
float3 | tangent | The output variable for the float3 tangent at t. |
float3 | upVector | The output variable for the float3 up direction at t. |
Returns
Type | Description |
---|---|
Boolean | True if a valid set of output variables is computed and false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
EvaluateAcceleration(Int32, Single)
Evaluates the acceleration vector of a point, t, on a spline at an index, `splineIndex, in world space.
Declaration
public float3 EvaluateAcceleration(int splineIndex, float t)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed acceleration vector. |
EvaluateAcceleration(Single)
Evaluates the acceleration vector of a point, t, on a spline in world space.
Declaration
public float3 EvaluateAcceleration(float t)
Parameters
Type | Name | Description |
---|---|---|
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed acceleration vector. |
EvaluateAcceleration<T>(T, Single)
Declaration
public float3 EvaluateAcceleration<T>(T spline, float t)
where T : ISpline
Parameters
Type | Name | Description |
---|---|---|
T | spline | |
Single | t |
Returns
Type | Description |
---|---|
float3 |
Type Parameters
Name | Description |
---|---|
T |
EvaluatePosition(Int32, Single)
Evaluates the position of a point, t, on a spline at an index, splineIndex
, in world space.
Declaration
public float3 EvaluatePosition(int splineIndex, float t)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of the curve. |
Returns
Type | Description |
---|---|
float3 | A world position along the spline. |
EvaluatePosition(Single)
valuates the position of a point, t, on a spline in world space.
Declaration
public float3 EvaluatePosition(float t)
Parameters
Type | Name | Description |
---|---|---|
Single | t | A value between 0 and 1 representing a percentage of the curve. |
Returns
Type | Description |
---|---|
float3 | A tangent vector. |
EvaluatePosition<T>(T, Single)
Evaluates the position of a point, t, on a given spline, in world space.
Declaration
public float3 EvaluatePosition<T>(T spline, float t)
where T : ISpline
Parameters
Type | Name | Description |
---|---|---|
T | spline | The spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of the curve. |
Returns
Type | Description |
---|---|
float3 | A world position along the spline. |
Type Parameters
Name | Description |
---|---|
T |
EvaluateTangent(Int32, Single)
Evaluates the tangent vector of a point, t, on a spline at an index, splineIndex
, in world space.
Declaration
public float3 EvaluateTangent(int splineIndex, float t)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed tangent vector. |
EvaluateTangent(Single)
Evaluates the tangent vector of a point, t, on a spline in world space.
Declaration
public float3 EvaluateTangent(float t)
Parameters
Type | Name | Description |
---|---|---|
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed tangent vector. |
EvaluateTangent<T>(T, Single)
Evaluates the tangent vector of a point, t, on a given spline, in world space.
Declaration
public float3 EvaluateTangent<T>(T spline, float t)
where T : ISpline
Parameters
Type | Name | Description |
---|---|---|
T | spline | The spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed tangent vector. |
Type Parameters
Name | Description |
---|---|
T |
EvaluateUpVector(Int32, Single)
Evaluates the up vector of a point, t, on a spline at an index, splineIndex
, in world space.
Declaration
public float3 EvaluateUpVector(int splineIndex, float t)
Parameters
Type | Name | Description |
---|---|---|
Int32 | splineIndex | The index of the Spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed up direction. |
EvaluateUpVector(Single)
Evaluates the up vector of a point, t, on a spline in world space.
Declaration
public float3 EvaluateUpVector(float t)
Parameters
Type | Name | Description |
---|---|---|
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed up direction. |
EvaluateUpVector<T>(T, Single)
Evaluates the up vector of a point, t, on a given spline, in world space.
Declaration
public float3 EvaluateUpVector<T>(T spline, float t)
where T : ISpline
Parameters
Type | Name | Description |
---|---|---|
T | spline | The Spline to evaluate. |
Single | t | A value between 0 and 1 representing a percentage of entire spline. |
Returns
Type | Description |
---|---|
float3 | The computed up direction. |
Type Parameters
Name | Description |
---|---|
T |
OnAfterDeserialize()
See ISerializationCallbackReceiver.
Declaration
public void OnAfterDeserialize()
Implements
OnBeforeSerialize()
See ISerializationCallbackReceiver.
Declaration
public void OnBeforeSerialize()