Class Spline
The Spline class is a collection of BezierKnot, the closed/open state, and editing representation.
Inherited Members
Namespace: UnityEngine.Splines
Syntax
[Serializable]
public class Spline : ISpline, IReadOnlyList<BezierKnot>, IReadOnlyCollection<BezierKnot>, IList<BezierKnot>, ICollection<BezierKnot>, IEnumerable<BezierKnot>, IEnumerable
Constructors
Spline()
Default constructor creates a spline with no knots, not closed.
Declaration
public Spline()
Spline(IEnumerable<BezierKnot>, Boolean)
Create a spline from a collection of BezierKnot.
Declaration
public Spline(IEnumerable<BezierKnot> knots, bool closed = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<BezierKnot> | knots | A collection of BezierKnot. |
Boolean | closed | Whether the spline is open (has a start and end point) or closed (forms an unbroken loop). |
Spline(Int32, Boolean)
Create a spline with a pre-allocated knot capacity.
Declaration
public Spline(int knotCapacity, bool closed = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | knotCapacity | The capacity of the knot collection. |
Boolean | closed | Whether the spline is open (has a start and end point) or closed (forms an unbroken loop). |
Spline(Spline)
Create a copy of a spline.
Declaration
public Spline(Spline spline)
Parameters
Type | Name | Description |
---|---|---|
Spline | spline | The spline to copy in that new instance. |
Properties
Closed
Whether the spline is open (has a start and end point) or closed (forms an unbroken loop).
Declaration
public bool Closed { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Count
Return the number of knots.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
IsReadOnly
Returns true if this Spline is read-only, false if it is mutable.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Item[Int32]
Get or set the knot at index
.
Declaration
public BezierKnot this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the element to get or set. |
Property Value
Type | Description |
---|---|
BezierKnot |
Implements
Knots
A collection of BezierKnot.
Declaration
public IEnumerable<BezierKnot> Knots { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<BezierKnot> |
Methods
Add(BezierKnot)
Adds a knot to the spline.
Declaration
public void Add(BezierKnot item)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The BezierKnot to add. |
Implements
Add(BezierKnot, TangentMode)
Adds a knot to the spline.
Declaration
public void Add(BezierKnot item, TangentMode mode)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The BezierKnot to add. |
TangentMode | mode | The tangent mode for this knot. |
Add(BezierKnot, TangentMode, Single)
Adds a knot to the spline.
Declaration
public void Add(BezierKnot item, TangentMode mode, float tension)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The BezierKnot to add. |
TangentMode | mode | The tangent mode for this knot. |
Single | tension | The modifier value that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded. |
Clear()
Remove all knots from the spline.
Declaration
public void Clear()
Implements
Contains(BezierKnot)
Return true if a knot is present in the spline.
Declaration
public bool Contains(BezierKnot item)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The BezierKnot to locate. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the knot is found, false if it is not present. |
Implements
Copy(Spline)
Copy the values from copyFrom
to this spline.
Declaration
public void Copy(Spline copyFrom)
Parameters
Type | Name | Description |
---|---|---|
Spline | copyFrom | The spline to copy property data from. |
CopyTo(BezierKnot[], Int32)
Copies the contents of the knot list to an array starting at an index.
Declaration
public void CopyTo(BezierKnot[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot[] | array | The destination array to place the copied item in. |
Int32 | arrayIndex | The zero-based index to copy. |
Implements
EnforceTangentModeNoNotify(Int32)
Ensure that a BezierKnot has the correct tangent and rotation values to match it's TangentMode and tension. This can be necessary if knot data is modified outside of the Spline class (ex, manually setting the Knots array without taking care to also set the tangent modes).
Declaration
public void EnforceTangentModeNoNotify(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The knot index to set tangent and rotation values for. |
EnforceTangentModeNoNotify(SplineRange)
Ensure that a BezierKnot has the correct tangent and rotation values to match it's TangentMode and tension. This can be necessary if knot data is modified outside of the Spline class (ex, manually setting the Knots array without taking care to also set the tangent modes).
Declaration
public void EnforceTangentModeNoNotify(SplineRange range)
Parameters
Type | Name | Description |
---|---|---|
SplineRange | range | The SplineRange range of knot indices to set tangent and rotation values for. |
GetAutoSmoothTension(Int32)
Gets the tension value for the requested index.
Declaration
public float GetAutoSmoothTension(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The knot index to get a tension value for. |
Returns
Type | Description |
---|---|
Single | Returns the tension value for the requested index. |
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
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
GetCurveLength(Int32)
Return the length of a curve.
Declaration
public float GetCurveLength(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Returns
Type | Description |
---|---|
Single |
Implements
See Also
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
GetFloat4DataKeys()
Get a collection of the keys of embedded SplineData<T> for this type.
Declaration
public IEnumerable<string> GetFloat4DataKeys()
Returns
Type | Description |
---|---|
IEnumerable<String> | An enumerable list of keys present for the requested type. |
GetFloat4DataValues()
Get a collection of the SplineData<T> values for this type.
Declaration
public IEnumerable<SplineData<float4>> GetFloat4DataValues()
Returns
Type | Description |
---|---|
IEnumerable<SplineData<float4>> | An enumerable list of values present for the requested type. |
GetFloatDataKeys()
Get a collection of the keys of embedded SplineData<T> for this type.
Declaration
public IEnumerable<string> GetFloatDataKeys()
Returns
Type | Description |
---|---|
IEnumerable<String> | An enumerable list of keys present for the requested type. |
GetFloatDataValues()
Get a collection of the SplineData<T> values for this type.
Declaration
public IEnumerable<SplineData<float>> GetFloatDataValues()
Returns
Type | Description |
---|---|
IEnumerable<SplineData<Single>> | An enumerable list of values present for the requested type. |
GetIntDataKeys()
Get a collection of the keys of embedded SplineData<T> for this type.
Declaration
public IEnumerable<string> GetIntDataKeys()
Returns
Type | Description |
---|---|
IEnumerable<String> | An enumerable list of keys present for the requested type. |
GetIntDataValues()
Get a collection of the SplineData<T> values for this type.
Declaration
public IEnumerable<SplineData<int>> GetIntDataValues()
Returns
Type | Description |
---|---|
IEnumerable<SplineData<Int32>> | An enumerable list of values present for the requested type. |
GetLength()
Return the sum of all curve lengths, accounting for Closed state. Note that this value is not accounting for transform hierarchy. If you require length in world space use
Declaration
public float GetLength()
Returns
Type | Description |
---|---|
Single | Returns the sum length of all curves composing this spline, accounting for closed state. |
Implements
Remarks
This value is cached. It is recommended to call this once in a non-performance critical path to ensure that the cache is valid.
See Also
GetObjectDataKeys()
Get a collection of the keys of embedded SplineData<T> for this type.
Declaration
public IEnumerable<string> GetObjectDataKeys()
Returns
Type | Description |
---|---|
IEnumerable<String> | An enumerable list of keys present for the requested type. |
GetObjectDataValues()
Get a collection of the SplineData<T> values for this type.
Declaration
public IEnumerable<SplineData<Object>> GetObjectDataValues()
Returns
Type | Description |
---|---|
IEnumerable<SplineData<Object>> | An enumerable list of values present for the requested type. |
GetOrCreateFloat4Data(String)
Returns a SplineData<T> for key
. If an instance matching the key and
type does not exist, a new entry is appended to the internal collection and returned.
Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to
this collection will affect the Spline data.
Declaration
public SplineData<float4> GetOrCreateFloat4Data(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
SplineData<float4> | A SplineData<T> of the requested type. |
GetOrCreateFloatData(String)
Returns a SplineData<T> for key
. If an instance matching the key and
type does not exist, a new entry is appended to the internal collection and returned.
Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to
this collection will affect the Spline data.
Declaration
public SplineData<float> GetOrCreateFloatData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
SplineData<Single> | A SplineData<T> of the requested type. |
GetOrCreateIntData(String)
Returns a SplineData<T> for key
. If an instance matching the key and
type does not exist, a new entry is appended to the internal collection and returned.
Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to
this collection will affect the Spline data.
Declaration
public SplineData<int> GetOrCreateIntData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
SplineData<Int32> | A SplineData<T> of the requested type. |
GetOrCreateObjectData(String)
Returns a SplineData<T> for key
. If an instance matching the key and
type does not exist, a new entry is appended to the internal collection and returned.
Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to
this collection will affect the Spline data.
Declaration
public SplineData<Object> GetOrCreateObjectData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
SplineData<Object> | A SplineData<T> of the requested type. |
GetSplineDataKeys(EmbeddedSplineDataType)
Get a collection of the keys of embedded SplineData<T> for this type.
Declaration
public IEnumerable<string> GetSplineDataKeys(EmbeddedSplineDataType type)
Parameters
Type | Name | Description |
---|---|---|
EmbeddedSplineDataType | type |
Returns
Type | Description |
---|---|
IEnumerable<String> | An enumerable list of keys present for the requested type. |
GetTangentMode(Int32)
Gets the TangentMode for a knot index.
Declaration
public TangentMode GetTangentMode(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index to retrieve TangentMode data for. |
Returns
Type | Description |
---|---|
TangentMode | A TangentMode for the knot at index. |
IndexOf(BezierKnot)
Return the first index of an element matching item.
Declaration
public int IndexOf(BezierKnot item)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The knot to locate. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the knot, or -1 if not found. |
Implements
Insert(Int32, BezierKnot)
Insert a BezierKnot at the specified index
.
Declaration
public void Insert(int index, BezierKnot knot)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index to insert the new element. |
BezierKnot | knot | The BezierKnot to insert. |
Implements
Insert(Int32, BezierKnot, TangentMode)
Inserts a BezierKnot at the specified index
.
Declaration
public void Insert(int index, BezierKnot knot, TangentMode mode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index to insert the new element. |
BezierKnot | knot | The BezierKnot to insert. |
TangentMode | mode | The TangentMode to apply to this knot. Tangent modes are enforced when a knot value is set. |
Insert(Int32, BezierKnot, TangentMode, Single)
Adds a BezierKnot at the specified index
.
Declaration
public void Insert(int index, BezierKnot knot, TangentMode mode, float tension)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index to insert the new element. |
BezierKnot | knot | The BezierKnot to insert. |
TangentMode | mode | The TangentMode to apply to this knot. Tangent modes are enforced when a knot value is set. |
Single | tension | The modifier value that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded. |
OnSplineChanged()
Invoked any time a spline property is modified.
Declaration
protected virtual void OnSplineChanged()
Remarks
In the editor this can be invoked many times per-frame. Prefer to use AfterSplineWasModified when working with splines in the editor.
Remove(BezierKnot)
Removes the first matching knot.
Declaration
public bool Remove(BezierKnot item)
Parameters
Type | Name | Description |
---|---|---|
BezierKnot | item | The BezierKnot to locate and remove. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a matching item was found and removed, false if no match was discovered. |
Implements
RemoveAt(Int32)
Removes the knot at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the element to remove. |
Implements
RemoveFloat4Data(String)
Remove a SplineData<T> value.
Declaration
public bool RemoveFloat4Data(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a matching SplineData<T> key value pair was found and removed, or false if no match was found. |
RemoveFloatData(String)
Remove a SplineData<T> value.
Declaration
public bool RemoveFloatData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a matching SplineData<T> key value pair was found and removed, or false if no match was found. |
RemoveIntData(String)
Remove a SplineData<T> value.
Declaration
public bool RemoveIntData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a matching SplineData<T> key value pair was found and removed, or false if no match was found. |
RemoveObjectData(String)
Remove a SplineData<T> value.
Declaration
public bool RemoveObjectData(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a matching SplineData<T> key value pair was found and removed, or false if no match was found. |
Resize(Int32)
Change the size of the BezierKnot list.
Declaration
public void Resize(int newSize)
Parameters
Type | Name | Description |
---|---|---|
Int32 | newSize | The new size of the knots collection. |
SetAutoSmoothTension(Int32, Single)
Sets the tension that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded.
Declaration
public void SetAutoSmoothTension(int index, float tension)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The knot index to set a tension value for. |
Single | tension | Set the length of the tangent vectors. |
SetAutoSmoothTension(SplineRange, Single)
Sets the tension that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded.
Declaration
public void SetAutoSmoothTension(SplineRange range, float tension)
Parameters
Type | Name | Description |
---|---|---|
SplineRange | range | The range of knot indices to set a tension value for. |
Single | tension | Set the length of the tangent vectors. |
SetAutoSmoothTensionNoNotify(Int32, Single)
Sets the tension that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded. No changed callbacks will be invoked.
Declaration
public void SetAutoSmoothTensionNoNotify(int index, float tension)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The knot index to set a tension value for. |
Single | tension | Set the length of the tangent vectors for a knot set to AutoSmooth. |
SetAutoSmoothTensionNoNotify(SplineRange, Single)
Set the tension that is used to calculate the magnitude of tangents when the TangentMode is AutoSmooth. Valid values are between 0 and 1. A lower value results in sharper curves, whereas higher values appear more rounded. No changed callbacks will be invoked.
Declaration
public void SetAutoSmoothTensionNoNotify(SplineRange range, float tension)
Parameters
Type | Name | Description |
---|---|---|
SplineRange | range | The range of knot indices to set a tension value for. |
Single | tension | Set the length of the tangent vectors for a knot set to AutoSmooth. |
SetFloat4Data(String, SplineData<float4>)
Set the SplineData<T> for .
Declaration
public void SetFloat4Data(string key, SplineData<float4> value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<float4> | value |
SetFloatData(String, SplineData<Single>)
Set the SplineData<T> for .
Declaration
public void SetFloatData(string key, SplineData<float> value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Single> | value | The SplineData<T> to set. This value will be copied. |
SetIntData(String, SplineData<Int32>)
Set the SplineData<T> for .
Declaration
public void SetIntData(string key, SplineData<int> value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Int32> | value |
SetKnot(Int32, BezierKnot, BezierTangent)
Sets the value of a knot at index.
Declaration
public void SetKnot(int index, BezierKnot value, BezierTangent main = BezierTangent.Out)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the BezierKnot to set. |
BezierKnot | value | The BezierKnot to set. |
BezierTangent | main | The tangent to prioritize if the tangents are modified to conform with the TangentMode set for this knot. |
SetKnotNoNotify(Int32, BezierKnot, BezierTangent)
Sets the value of a knot index without invoking any change callbacks.
Declaration
public void SetKnotNoNotify(int index, BezierKnot value, BezierTangent main = BezierTangent.Out)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the BezierKnot to set. |
BezierKnot | value | The BezierKnot to set. |
BezierTangent | main | The tangent to prioritize if the tangents are modified to conform with the TangentMode set for this knot. |
SetObjectData(String, SplineData<Object>)
Set the SplineData<T> for .
Declaration
public void SetObjectData(string key, SplineData<Object> value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Object> | value |
SetTangentMode(Int32, TangentMode, BezierTangent)
Sets the TangentMode for a knot, and ensures that the rotation and tangent values match the behavior of the tangent mode. This function can modify the contents of the BezierKnot at the specified index.
Declaration
public void SetTangentMode(int index, TangentMode mode, BezierTangent main = BezierTangent.Out)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the knot to set. |
TangentMode | mode | The mode to set. |
BezierTangent | main | The tangent direction to align both the In and Out tangent when assigning Continuous or Mirrored tangent mode. |
SetTangentMode(SplineRange, TangentMode, BezierTangent)
Sets the TangentMode for a series of knots, and ensures that the rotation and tangent values match the behavior of the tangent mode. This function can modify the contents of the BezierKnot at the specified indices.
Declaration
public void SetTangentMode(SplineRange range, TangentMode mode, BezierTangent main = BezierTangent.Out)
Parameters
Type | Name | Description |
---|---|---|
SplineRange | range | The range of knot indices to set. |
TangentMode | mode | The mode to set. |
BezierTangent | main | The tangent direction to align both the In and Out tangent with when Continuous or Mirrored tangent mode is assigned . |
SetTangentMode(TangentMode)
Sets the TangentMode for all knots on this spline.
Declaration
public void SetTangentMode(TangentMode mode)
Parameters
Type | Name | Description |
---|---|---|
TangentMode | mode | The TangentMode to apply to each knot. |
SetTangentModeNoNotify(Int32, TangentMode, BezierTangent)
Sets the TangentMode for a knot, and ensures that the rotation and tangent values match the behavior of the tangent mode. No changed callbacks will be invoked. This function can modify the contents of the BezierKnot at the specified index.
Declaration
public void SetTangentModeNoNotify(int index, TangentMode mode, BezierTangent main = BezierTangent.Out)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the knot to set. |
TangentMode | mode | The mode to set. |
BezierTangent | main | The tangent direction to align both the In and Out tangent when assigning Continuous or Mirrored tangent mode. |
ToArray()
Create an array of spline knots.
Declaration
public BezierKnot[] ToArray()
Returns
Type | Description |
---|---|
BezierKnot[] | Return a new array copy of the knots collection. |
TryGetFloat4Data(String, out SplineData<float4>)
Retrieve a SplineData<T> reference for if it exists. Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to this collection will affect the Spline data.
Declaration
public bool TryGetFloat4Data(string key, out SplineData<float4> data)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<float4> | data |
Returns
Type | Description |
---|---|
Boolean | True if the key and type combination are found, otherwise false. |
TryGetFloatData(String, out SplineData<Single>)
Retrieve a SplineData<T> reference for if it exists. Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to this collection will affect the Spline data.
Declaration
public bool TryGetFloatData(string key, out SplineData<float> data)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Single> | data | The output SplineData<T> if the key is found. |
Returns
Type | Description |
---|---|
Boolean | True if the key and type combination are found, otherwise false. |
TryGetIntData(String, out SplineData<Int32>)
Retrieve a SplineData<T> reference for if it exists. Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to this collection will affect the Spline data.
Declaration
public bool TryGetIntData(string key, out SplineData<int> data)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Int32> | data |
Returns
Type | Description |
---|---|
Boolean | True if the key and type combination are found, otherwise false. |
TryGetObjectData(String, out SplineData<Object>)
Retrieve a SplineData<T> reference for if it exists. Note that this is a reference to the stored SplineData<T>, not a copy. Any modifications to this collection will affect the Spline data.
Declaration
public bool TryGetObjectData(string key, out SplineData<Object> data)
Parameters
Type | Name | Description |
---|---|---|
String | key | The string key value to search for. Only one instance of a key value can exist in an embedded SplineData<T> collection, however keys are unique to each data type. The same key can be re-used to store float data and Object data. |
SplineData<Object> | data |
Returns
Type | Description |
---|---|
Boolean | True if the key and type combination are found, otherwise false. |
Warmup()
Ensure that all caches contain valid data. Call this to avoid unexpected performance costs when accessing spline data. Caches remain valid until any part of the spline state is modified.
Declaration
public void Warmup()
Events
Changed
Invoked any time a spline is modified.
Declaration
public static event Action<Spline, int, SplineModification> Changed
Event Type
Type | Description |
---|---|
Action<Spline, Int32, SplineModification> |
Remarks
First parameter is the target Spline that the event is raised for, second parameter is the knot index and the third parameter represents the type of change that occurred. If the event does not target a specific knot, the second parameter will have the value of -1.
In the editor this callback can be invoked many times per-frame. Prefer to use AfterSplineWasModified when working with splines in the editor.
See Also
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. |