docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SplineUtility

    A collection of methods for extracting information about Spline types.

    Inheritance
    object
    SplineUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Splines
    Assembly: Unity.Splines.dll
    Syntax
    public static class SplineUtility
    Remarks

    SplineUtility methods do not consider Transform values except where explicitly requested. To perform operations in world space, you can use the SplineContainer evaluate methods or build a NativeSpline with a constructor that accepts a matrix and evaluate that spline.

    Fields

    CatmullRomTension

    The tension value for a Catmull-Rom type spline. Use with SetTangentMode(TangentMode) and SetAutoSmoothTension(int, float) to control the curvature of the spline at control points.

    Declaration
    public const float CatmullRomTension = 0.5
    Field Value
    Type Description
    float

    DefaultTension

    The default tension value used for AutoSmooth knots. Use with SetTangentMode(TangentMode) and SetAutoSmoothTension(int, float) to control the curvature of the spline at control points.

    Declaration
    public const float DefaultTension = 0.33333334
    Field Value
    Type Description
    float

    DrawResolutionDefault

    The default resolution used when unrolling a curve to draw a preview in the Scene View.

    Pick resolution is used when determining how many segments are required to unroll a curve. Unrolling is the process of calculating a series of line segments to approximate a curve. Some functions in SplineUtility allow you to specify a resolution. Lower resolution means fewer segments, while higher resolutions result in more segments. Use lower resolutions where performance is critical and accuracy is not paramount. Use higher resolution where a fine degree of accuracy is necessary and performance is less important.

    Declaration
    public const int DrawResolutionDefault = 10
    Field Value
    Type Description
    int

    PickResolutionDefault

    The default resolution used when unrolling a curve to hit test while picking (selecting a spline with a cursor).

    Pick resolution is used when determining how many segments are required to unroll a curve. Unrolling is the process of calculating a series of line segments to approximate a curve. Some functions in SplineUtility allow you to specify a resolution. Lower resolution means fewer segments, while higher resolutions result in more segments. Use lower resolutions where performance is critical and accuracy is not paramount. Use higher resolution where a fine degree of accuracy is necessary and performance is less important.

    Declaration
    public const int PickResolutionDefault = 4
    Field Value
    Type Description
    int

    PickResolutionMax

    The maximum resolution allowed when unrolling a curve to hit test while picking (selecting a spline with a cursor).

    Pick resolution is used when determining how many segments are required to unroll a curve. Unrolling is the process of calculating a series of line segments to approximate a curve. Some functions in SplineUtility allow you to specify a resolution. Lower resolution means fewer segments, while higher resolutions result in more segments. Use lower resolutions where performance is critical and accuracy is not paramount. Use higher resolution where a fine degree of accuracy is necessary and performance is less important.

    Declaration
    public const int PickResolutionMax = 64
    Field Value
    Type Description
    int

    PickResolutionMin

    The minimum resolution allowable when unrolling a curve to hit test while picking (selecting a spline with a cursor).

    Pick resolution is used when determining how many segments are required to unroll a curve. Unrolling is the process of calculating a series of line segments to approximate a curve. Some functions in SplineUtility allow you to specify a resolution. Lower resolution means fewer segments, while higher resolutions result in more segments. Use lower resolutions where performance is critical and accuracy is not paramount. Use higher resolution where a fine degree of accuracy is necessary and performance is less important.

    Declaration
    public const int PickResolutionMin = 2
    Field Value
    Type Description
    int

    Methods

    AddSpline<T>(T)

    Creates a new spline and adds it to the ISplineContainer.

    Declaration
    public static Spline AddSpline<T>(this T container) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target container.

    Returns
    Type Description
    Spline

    Returns the spline that was created and added to the container.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    AddSpline<T>(T, Spline)

    Add a new Spline to the ISplineContainer.

    Declaration
    public static void AddSpline<T>(this T container, Spline spline) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target container.

    Spline spline

    The spline to append to this container.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    AreKnotLinked(ISplineContainer, SplineKnotIndex, SplineKnotIndex)

    Checks if two knots from an ISplineContainer are linked together.

    Declaration
    public static bool AreKnotLinked(this ISplineContainer container, SplineKnotIndex knotA, SplineKnotIndex knotB)
    Parameters
    Type Name Description
    ISplineContainer container

    The target SplineContainer.

    SplineKnotIndex knotA

    The first knot to check.

    SplineKnotIndex knotB

    The second knot to check against.

    Returns
    Type Description
    bool

    Returns true if knotA and knotB are linked; otherwise, false.

    CalculateLength<T>(T, float4x4)

    Calculate the length of a spline when transformed by a matrix.

    Declaration
    public static float CalculateLength<T>(this T spline, float4x4 transform) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline whose length is to be calculated.

    float4x4 transform

    The transformation matrix to apply to the spline.

    Returns
    Type Description
    float

    The length of the transformed spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    CalculateUpVector<T>(T, float)

    Calculate the normal (up) vector of a spline. This is a more accurate but more expensive operation than EvaluateUpVector<T>(T, float).

    Declaration
    public static float3 CalculateUpVector<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The NativeSpline to evaluate.

    float t

    A value between 0 and 1 representing a ratio of the curve.

    Returns
    Type Description
    float3

    An up vector

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    ConvertIndexUnit<T>(T, float, PathIndexUnit)

    Given a normalized interpolation ratio, calculate the associated interpolation value in another PathIndexUnit regarding a specific spline.

    Declaration
    public static float ConvertIndexUnit<T>(this T spline, float t, PathIndexUnit targetPathUnit) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The Spline to use for the conversion.

    float t

    Normalized interpolation ratio (0 to 1).

    PathIndexUnit targetPathUnit

    The PathIndexUnit to which t should be converted.

    Returns
    Type Description
    float

    The interpolation value converted to targetPathUnit.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    ConvertIndexUnit<T>(T, float, PathIndexUnit, PathIndexUnit)

    Given an interpolation value using one of the various PathIndexUnit types, calculate the associated interpolation value in another PathIndexUnit regarding a specific spline.

    Declaration
    public static float ConvertIndexUnit<T>(this T spline, float value, PathIndexUnit fromPathUnit, PathIndexUnit targetPathUnit) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to use for the conversion.

    float value

    Interpolation value in the original PathIndexUnit fromPathUnit.

    PathIndexUnit fromPathUnit

    The PathIndexUnit for the original interpolation value type.

    PathIndexUnit targetPathUnit

    The PathIndexUnit to which value should be converted.

    Returns
    Type Description
    float

    The interpolation value converted to targetPathUnit.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    CopyKnotLinks<T>(T, int, int)

    Copies knot links between two splines of the same ISplineContainer.

    Declaration
    public static void CopyKnotLinks<T>(this T container, int srcSplineIndex, int destSplineIndex) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target SplineContainer.

    int srcSplineIndex

    The index of the source spline to copy from.

    int destSplineIndex

    The index of the destination spline to copy to.

    Type Parameters
    Name Description
    T

    A type implementing ISplineContainer.

    Remarks

    The knot links will only be copied if both of the spline indices are valid and both splines have the same amount of knots.

    CurveToSplineT<T>(T, float)

    Given an interpolation value for a curve, calculate the relative normalized spline interpolation.

    Declaration
    public static float CurveToSplineT<T>(this T spline, float curve) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The target spline.

    float curve

    A curve index and normalized interpolation. The curve index is represented by the integer part of the float, and interpolation is the fractional part. This is the format used by Knot.

    Returns
    Type Description
    float

    An interpolation value relative to normalized Spline length (0 to 1).

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    See Also
    SplineToCurveT<T>(T, float, out float)

    DuplicateSpline(ISplineContainer, SplineKnotIndex, SplineKnotIndex, out int)

    Duplicate a spline between 2 knots of a source spline.

    Declaration
    public static void DuplicateSpline(this ISplineContainer container, SplineKnotIndex fromKnot, SplineKnotIndex toKnot, out int newSplineIndex)
    Parameters
    Type Name Description
    ISplineContainer container

    The target SplineContainer.

    SplineKnotIndex fromKnot

    The start knot to use to duplicate the spline.

    SplineKnotIndex toKnot

    The end knot to use to duplicate the spline.

    int newSplineIndex

    The index of the new created spline in the container.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the provided knots aren't valid or aren't on the same spline.

    EvaluateAcceleration<T>(T, float)

    Return an interpolated acceleration at ratio t.

    Declaration
    public static float3 EvaluateAcceleration<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    An acceleration on the spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    EvaluateCurvatureCenter<T>(T, float)

    Return the curvature center at ratio t. The curvature center represents the center of the circle that is tangent to the curve at t. This circle is in the plane defined by the curve velocity (tangent) and the curve acceleration at that point.

    Declaration
    public static float3 EvaluateCurvatureCenter<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    A point representing the curvature center associated to the position at t on the spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    EvaluateCurvature<T>(T, float)

    Return an interpolated curvature at ratio t.

    Declaration
    public static float EvaluateCurvature<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float

    A curvature on the spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    EvaluateNurbs(float, List<float3>, List<double>, int, out float3)

    Computes the interpolated position for NURBS defined by order, controlPoints, and knotVector at ratio t.

    Declaration
    public static bool EvaluateNurbs(float t, List<float3> controlPoints, List<double> knotVector, int order, out float3 position)
    Parameters
    Type Name Description
    float t

    The value between knotVector[0] and knotVector[-1] that represents the ratio along the curve.

    List<float3> controlPoints

    The control points for the NURBS.

    List<double> knotVector

    The knot vector for the NURBS. There must be at least order + controlPoints.Length - 1 knots.

    int order

    The order of the curve. For example, 4 for a cubic curve or 3 for quadratic.

    float3 position

    The output variable for the float3 position at t.

    Returns
    Type Description
    bool

    True if successful.

    EvaluatePosition<T>(T, float)

    Return an interpolated position at ratio t.

    Declaration
    public static float3 EvaluatePosition<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    A position on the spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    EvaluateTangent<T>(T, float)

    Return an interpolated direction at ratio t.

    Declaration
    public static float3 EvaluateTangent<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    A direction on the spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    EvaluateUpVector<T>(T, float)

    Evaluate the normal (up) vector of a spline.

    Declaration
    public static float3 EvaluateUpVector<T>(this T spline, float t) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to evaluate.

    float t

    A value between 0 and 1 representing a ratio of the curve.

    Returns
    Type Description
    float3

    An up vector

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    Evaluate<T>(T, float, out float3, out float3, out float3)

    Compute interpolated position, direction and upDirection at ratio t. Calling this method to get the 3 vectors is faster than calling independently EvaluatePosition, EvaluateDirection and EvaluateUpVector for the same time t as it reduces some redundant computation.

    Declaration
    public static bool Evaluate<T>(this 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 interpolate.

    float t

    A value between 0 and 1 representing the ratio along the curve.

    float3 position

    Output variable for the float3 position at t.

    float3 tangent

    Output variable for the float3 tangent at t.

    float3 upVector

    Output variable for the float3 up direction at t.

    Returns
    Type Description
    bool

    True if successful.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    FitSplineToPoints(List<float3>, float, bool, out Spline)

    Computes a Spline to approximate the curve formed by the list of provided points within the given error threshold.

    Declaration
    public static bool FitSplineToPoints(List<float3> points, float errorThreshold, bool closed, out Spline spline)
    Parameters
    Type Name Description
    List<float3> points

    The list of Unity.Mathematics.float3 points that define the curve to approximate.

    float errorThreshold

    The error threshold to use. Represents the largest distance between any of the provided points and the curve.

    bool closed

    Whether to close the Spline.

    Spline spline

    The output Spline fitted to the points, or an empty spline if could not be fitted.

    Returns
    Type Description
    bool

    Whether a curve could be fitted according to the provided error threshold.

    GetAutoSmoothKnot(float3, float3, float3)

    Gets a BezierKnot with its tangents and rotation calculated using the previous and next knot positions.

    Declaration
    public static BezierKnot GetAutoSmoothKnot(float3 position, float3 previous, float3 next)
    Parameters
    Type Name Description
    float3 position

    The position of the knot.

    float3 previous

    The knot that immediately precedes the requested knot.

    float3 next

    The knot that immediately follows the requested knot.

    Returns
    Type Description
    BezierKnot

    A BezierKnot with tangent and rotation values calculated from the previous and next knot positions.

    GetAutoSmoothKnot(float3, float3, float3, float3)

    Gets a BezierKnot with its tangents and rotation calculated using the previous and next knot positions.

    Declaration
    public static BezierKnot GetAutoSmoothKnot(float3 position, float3 previous, float3 next, float3 normal)
    Parameters
    Type Name Description
    float3 position

    The position of the knot.

    float3 previous

    The knot that immediately precedes the requested knot.

    float3 next

    The knot that immediately follows the requested knot.

    float3 normal

    The normal vector of the knot.

    Returns
    Type Description
    BezierKnot

    A BezierKnot with tangent and rotation values calculated from the previous and next knot positions.

    GetAutoSmoothKnot(float3, float3, float3, float3, float)

    Gets a BezierKnot with its tangents and rotation calculated using the previous and next knot positions.

    Declaration
    public static BezierKnot GetAutoSmoothKnot(float3 position, float3 previous, float3 next, float3 normal, float tension = 0.33333334)
    Parameters
    Type Name Description
    float3 position

    The position of the knot.

    float3 previous

    The knot that immediately precedes the requested knot.

    float3 next

    The knot that immediately follows the requested knot.

    float3 normal

    The normal vector of the knot.

    float tension

    Set the length of the tangent vectors.

    Returns
    Type Description
    BezierKnot

    A BezierKnot with tangent and rotation values calculated from the previous and next knot positions.

    GetAutoSmoothTangent(float3, float3, float)

    Calculates a tangent from the previous and next knot positions.

    Declaration
    public static float3 GetAutoSmoothTangent(float3 previous, float3 next, float tension = 0.33333334)
    Parameters
    Type Name Description
    float3 previous

    The position of the previous BezierKnot.

    float3 next

    The position of the next BezierKnot.

    float tension

    Set the length of the tangent vectors.

    Returns
    Type Description
    float3

    Returns a tangent calculated from the previous and next knot positions.

    GetAutoSmoothTangent(float3, float3, float3, float)

    Gets a tangent from the previous, current, and next knot positions.

    Declaration
    public static float3 GetAutoSmoothTangent(float3 previous, float3 current, float3 next, float tension = 0.33333334)
    Parameters
    Type Name Description
    float3 previous

    The position of the previous BezierKnot.

    float3 current

    The position of the current BezierKnot.

    float3 next

    The position of the next BezierKnot.

    float tension

    The length of the tangent vectors.

    Returns
    Type Description
    float3

    Returns a tangent calculated from the previous, current, and next knot positions.

    GetBounds<T>(T)

    Calculate the bounding box of a Spline.

    Declaration
    public static Bounds GetBounds<T>(this T spline) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline for which to calculate bounds.

    Returns
    Type Description
    Bounds

    The bounds of a spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetBounds<T>(T, float4x4)

    Creates a bounding box for a spline.

    Declaration
    public static Bounds GetBounds<T>(this T spline, float4x4 transform) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to calculate bounds for.

    float4x4 transform

    The matrix to transform the spline's elements with.

    Returns
    Type Description
    Bounds

    The bounds of a spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetCatmullRomTangent(float3, float3)

    Calculates a tangent from the previous and next knot positions.

    Declaration
    public static float3 GetCatmullRomTangent(float3 previous, float3 next)
    Parameters
    Type Name Description
    float3 previous

    The position of the previous BezierKnot.

    float3 next

    The position of the next BezierKnot.

    Returns
    Type Description
    float3

    Returns a tangent calculated from the previous and next knot positions.

    GetCurveCount<T>(T)

    Calculates the number of curves in a spline.

    Declaration
    public static int GetCurveCount<T>(this T spline) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline for which to calculate the number of curves.

    Returns
    Type Description
    int

    The number of curves in a spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetNearestPoint<T>(T, float3, out float3, out float, int, int)

    Calculate the point on a spline nearest to a point.

    Declaration
    public static float GetNearestPoint<T>(T spline, float3 point, out float3 nearest, out float t, int resolution = 4, int iterations = 2) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The input spline to search for nearest point.

    float3 point

    The input point to compare.

    float3 nearest

    The point on a spline nearest to the input point. The accuracy of this value is affected by the resolution.

    float t

    The normalized interpolation ratio corresponding to the nearest point.

    int resolution

    Affects how many segments to split a spline into when calculating the nearest point. Higher values mean smaller and more segments, which increases accuracy at the cost of processing time. The minimum resolution is defined by PickResolutionMin, and the maximum is defined by PickResolutionMax. In most cases, the default resolution is appropriate. Use with iterations to fine tune point accuracy.

    int iterations

    The nearest point is calculated by finding the nearest point on the entire length of the spline using resolution to divide into equally spaced line segments. Successive iterations will then subdivide further the nearest segment, producing more accurate results. In most cases, the default value is sufficient, but if extreme accuracy is required this value can be increased to a maximum of PickResolutionMax.

    Returns
    Type Description
    float

    The distance from input point to nearest point on spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetNearestPoint<T>(T, Ray, out float3, out float, int, int)

    Calculate the point on a spline nearest to a ray.

    Declaration
    public static float GetNearestPoint<T>(T spline, Ray ray, out float3 nearest, out float t, int resolution = 4, int iterations = 2) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The input spline to search for nearest point.

    Ray ray

    The input ray to search against.

    float3 nearest

    The point on a spline nearest to the input ray. The accuracy of this value is affected by the resolution.

    float t

    The normalized time value to the nearest point.

    int resolution

    Affects how many segments to split a spline into when calculating the nearest point. Higher values mean smaller and more segments, which increases accuracy at the cost of processing time. The minimum resolution is defined by PickResolutionMin, and the maximum is defined by PickResolutionMax. In most cases, the default resolution is appropriate. Use with iterations to fine tune point accuracy.

    int iterations

    The nearest point is calculated by finding the nearest point on the entire length of the spline using resolution to divide into equally spaced line segments. Successive iterations will then subdivide further the nearest segment, producing more accurate results. In most cases, the default value is sufficient, but if extreme accuracy is required this value can be increased to a maximum of PickResolutionMax.

    Returns
    Type Description
    float

    The distance from ray to nearest point.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetNormalizedInterpolation<T>(T, float, PathIndexUnit)

    Given an interpolation value in any PathIndexUnit type, calculate the normalized interpolation ratio value relative to a Spline.

    Declaration
    public static float GetNormalizedInterpolation<T>(T spline, float t, PathIndexUnit originalPathUnit) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The Spline to use for the conversion, this is necessary to compute Normalized and Distance PathIndexUnits.

    float t

    The t value to normalize in the original PathIndexUnit.

    PathIndexUnit originalPathUnit

    The PathIndexUnit from the original t.

    Returns
    Type Description
    float

    The normalized interpolation ratio (0 to 1).

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetPointAtLinearDistance<T>(T, float, float, out float)

    Given a Spline and interpolation ratio, calculate the 3d point at a linear distance from point at spline.EvaluatePosition(t). Returns the corresponding time associated to this 3d position on the Spline.

    Declaration
    public static float3 GetPointAtLinearDistance<T>(this T spline, float fromT, float relativeDistance, out float resultPointT) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The Spline on which to compute the point.

    float fromT

    The Spline interpolation ratio t (normalized) from which the next position need to be computed.

    float relativeDistance

    The relative distance at which the new point should be placed. A negative value will compute a point at a resultPointTime previous to fromT (backward search).

    float resultPointT

    The normalized interpolation ratio of the resulting point.

    Returns
    Type Description
    float3

    The 3d point from the spline located at a linear distance from the point at t.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    GetSubdivisionCount(float, int)

    Gets the number of subdivisions for a spline length and resolution.

    Declaration
    public static int GetSubdivisionCount(float length, int resolution)
    Parameters
    Type Name Description
    float length

    The length of the spline to consider.

    int resolution

    The resolution to consider. Higher resolutions result in more precise representations. However, higher resolutions have higher performance requirements.

    Returns
    Type Description
    int

    The number of subdivisions as calculated for given length and resolution.

    JoinSplinesOnKnots(ISplineContainer, SplineKnotIndex, SplineKnotIndex)

    Joins two splines together at the specified knots. The two splines must belong to the same container and the knots must be at an extremity of their respective splines.

    Declaration
    public static SplineKnotIndex JoinSplinesOnKnots(this ISplineContainer container, SplineKnotIndex mainKnot, SplineKnotIndex otherKnot)
    Parameters
    Type Name Description
    ISplineContainer container

    The target SplineContainer.

    SplineKnotIndex mainKnot

    The first spline extremity to join.

    SplineKnotIndex otherKnot

    The second spline extremity to join.

    Returns
    Type Description
    SplineKnotIndex

    The SplineKnotIndex of the junction knot.

    Remarks

    In case a spline needs to be reversed to join the two extremities, the mainKnot defines which spline will be kept. Hence, the second one will be the reversed one.

    Exceptions
    Type Condition
    ArgumentException

    An exception is thrown on impossible join request (out of bounds parameters, knots on the same spline, non-extremity knots)

    LinkKnots<T>(T, SplineKnotIndex, SplineKnotIndex)

    Links two knots in an ISplineContainer. The two knots can be on different splines, but both must be in the referenced SplineContainer. If these knots are linked to other knots, all existing links are kept and updated.

    Declaration
    public static void LinkKnots<T>(this T container, SplineKnotIndex knotA, SplineKnotIndex knotB) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target SplineContainer.

    SplineKnotIndex knotA

    The first knot to link.

    SplineKnotIndex knotB

    The second knot to link.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    NextIndex<T>(T, int)

    Gets the index of a knot that follows a spline index. This method uses the Count and Closed properties to ensure that it returns the correct index of the knot.

    Declaration
    public static int NextIndex<T>(this T spline, int index) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to consider.

    int index

    The current index to consider.

    Returns
    Type Description
    int

    The knot index after index on the considered spline.

    Type Parameters
    Name Description
    T

    A type that implements ISpline.

    Next<T>(T, int)

    Gets the BezierKnot after spline[index]. This method uses the Count and Closed properties to ensure that it returns the correct knot.

    Declaration
    public static BezierKnot Next<T>(this T spline, int index) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to consider.

    int index

    The current index to consider.

    Returns
    Type Description
    BezierKnot

    The knot after the knot at spline[index].

    Type Parameters
    Name Description
    T

    A type that implements ISpline.

    PreviousIndex<T>(T, int)

    Gets the index of a knot that precedes a spline index. This method uses the Count and Closed properties to ensure that it returns the correct index of the knot.

    Declaration
    public static int PreviousIndex<T>(this T spline, int index) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to consider.

    int index

    The current index to consider.

    Returns
    Type Description
    int

    Returns a knot index that precedes the index on the considered spline.

    Type Parameters
    Name Description
    T

    A type that implements ISpline.

    Previous<T>(T, int)

    Gets the BezierKnot before spline[index]. This method uses the Count and Closed properties to ensure that it returns the correct knot.

    Declaration
    public static BezierKnot Previous<T>(this T spline, int index) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to consider.

    int index

    The current index to consider.

    Returns
    Type Description
    BezierKnot

    The knot before the knot at spline[index].

    Type Parameters
    Name Description
    T

    A type that implements ISpline.

    ReducePoints<T>(T, List<float3>, float)

    Removes redundant points in a poly line to form a similar shape with fewer points.

    Declaration
    public static void ReducePoints<T>(T line, List<float3> results, float epsilon = 0.15) where T : IList<float3>
    Parameters
    Type Name Description
    T line

    The poly line to act on.

    List<float3> results

    A pre-allocated list to be filled with the new reduced line points.

    float epsilon

    The maximum distance from the reduced poly line shape for a point to be discarded.

    Type Parameters
    Name Description
    T

    The collection type. Usually this will be list or array of float3.

    ReducePoints<T>(T, float)

    Removes redundant points in a poly line to form a similar shape with fewer points.

    Declaration
    public static List<float3> ReducePoints<T>(T line, float epsilon = 0.15) where T : IList<float3>
    Parameters
    Type Name Description
    T line

    The poly line to act on.

    float epsilon

    The maximum distance from the reduced poly line shape for a point to be discarded.

    Returns
    Type Description
    List<float3>

    Returns a new list with a poly line matching the shape of the original line with fewer points.

    Type Parameters
    Name Description
    T

    The collection type. Usually this will be list or array of float3.

    RemoveSplineAt<T>(T, int)

    Removes a spline from a ISplineContainer.

    Declaration
    public static bool RemoveSplineAt<T>(this T container, int splineIndex) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target container.

    int splineIndex

    The index of the spline to remove from the SplineContainer.

    Returns
    Type Description
    bool

    Returns true if the spline was removed from the container.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    RemoveSpline<T>(T, Spline)

    Removes a spline from a ISplineContainer.

    Declaration
    public static bool RemoveSpline<T>(this T container, Spline spline) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target SplineContainer.

    Spline spline

    The spline to remove from the SplineContainer.

    Returns
    Type Description
    bool

    Returns true if the spline was removed from the container.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    ReorderSpline<T>(T, int, int)

    Reorders a spline in a ISplineContainer.

    Declaration
    public static bool ReorderSpline<T>(this T container, int previousSplineIndex, int newSplineIndex) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target SplineContainer.

    int previousSplineIndex

    The previous index of the spline to reorder in the SplineContainer.

    int newSplineIndex

    The new index of the spline to reorder in the SplineContainer.

    Returns
    Type Description
    bool

    Returns true if the spline was reordered in the container.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    ReverseFlow(ISplineContainer, int)

    Reverses the flow direction of a spline.

    Declaration
    public static void ReverseFlow(this ISplineContainer container, int splineIndex)
    Parameters
    Type Name Description
    ISplineContainer container

    The target SplineContainer.

    int splineIndex

    The index of the spline to reverse.

    ReverseFlow(Spline)

    Reverses the flow direction of a spline. Should only be used with Splines that aren't inside any container.

    Declaration
    public static void ReverseFlow(Spline spline)
    Parameters
    Type Name Description
    Spline spline

    The spline to reverse.

    ReverseFlow(SplineInfo)

    Reverses the flow direction of a spline.

    Declaration
    public static void ReverseFlow(SplineInfo splineInfo)
    Parameters
    Type Name Description
    SplineInfo splineInfo

    The spline to reverse.

    SetLinkedKnotPosition<T>(T, SplineKnotIndex)

    Sets the position of all knots linked to the knot at index in an ISplineContainer to the same position.

    Declaration
    public static void SetLinkedKnotPosition<T>(this T container, SplineKnotIndex index) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target container.

    SplineKnotIndex index

    The SplineKnotIndex of the knot to use to synchronize the positions.

    Type Parameters
    Name Description
    T

    A type that implements ISplineContainer.

    SetPivot(SplineContainer, Vector3)

    Reset a transform position to a position while keeping knot positions in the same place. This modifies both knot positions and transform position.

    Declaration
    public static void SetPivot(SplineContainer container, Vector3 position)
    Parameters
    Type Name Description
    SplineContainer container

    The target spline.

    Vector3 position

    The point in world space to move the pivot to.

    SplineToCurveT<T>(T, float, out float)

    Given a normalized interpolation (t) for a spline, calculate the curve index and curve-relative normalized interpolation.

    Declaration
    public static int SplineToCurveT<T>(this T spline, float splineT, out float curveT) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The target spline.

    float splineT

    A normalized spline interpolation value to be converted into curve space.

    float curveT

    A normalized curve interpolation value.

    Returns
    Type Description
    int

    The curve index.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    SplitSplineOnKnot(ISplineContainer, SplineKnotIndex)

    Splits a spline in a SplineContainer into two splines at a specified knot.

    Declaration
    public static SplineKnotIndex SplitSplineOnKnot(this ISplineContainer container, SplineKnotIndex knotInfo)
    Parameters
    Type Name Description
    ISplineContainer container

    The target SplineContainer.

    SplineKnotIndex knotInfo

    The SplineKnotIndex of the spline to split.

    Returns
    Type Description
    SplineKnotIndex

    The SplineKnotIndex of the first knot of the spline that was created from the split.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    An exception is thrown when the knot belongs to a spline not contained by the provided container or when the knot index is out of range.

    UnlinkKnots<T>(T, IReadOnlyList<SplineKnotIndex>)

    Unlinks several knots from an ISplineContainer. A knot in knots disconnects from other knots it was linked to.

    Declaration
    public static void UnlinkKnots<T>(this T container, IReadOnlyList<SplineKnotIndex> knots) where T : ISplineContainer
    Parameters
    Type Name Description
    T container

    The target SplineContainer.

    IReadOnlyList<SplineKnotIndex> knots

    The knot to unlink.

    Type Parameters
    Name Description
    T

    A type implementing ISplineContainer.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Fields
      • CatmullRomTension
      • DefaultTension
      • DrawResolutionDefault
      • PickResolutionDefault
      • PickResolutionMax
      • PickResolutionMin
    • Methods
      • AddSpline<T>(T)
      • AddSpline<T>(T, Spline)
      • AreKnotLinked(ISplineContainer, SplineKnotIndex, SplineKnotIndex)
      • CalculateLength<T>(T, float4x4)
      • CalculateUpVector<T>(T, float)
      • ConvertIndexUnit<T>(T, float, PathIndexUnit)
      • ConvertIndexUnit<T>(T, float, PathIndexUnit, PathIndexUnit)
      • CopyKnotLinks<T>(T, int, int)
      • CurveToSplineT<T>(T, float)
      • DuplicateSpline(ISplineContainer, SplineKnotIndex, SplineKnotIndex, out int)
      • EvaluateAcceleration<T>(T, float)
      • EvaluateCurvatureCenter<T>(T, float)
      • EvaluateCurvature<T>(T, float)
      • EvaluateNurbs(float, List<float3>, List<double>, int, out float3)
      • EvaluatePosition<T>(T, float)
      • EvaluateTangent<T>(T, float)
      • EvaluateUpVector<T>(T, float)
      • Evaluate<T>(T, float, out float3, out float3, out float3)
      • FitSplineToPoints(List<float3>, float, bool, out Spline)
      • GetAutoSmoothKnot(float3, float3, float3)
      • GetAutoSmoothKnot(float3, float3, float3, float3)
      • GetAutoSmoothKnot(float3, float3, float3, float3, float)
      • GetAutoSmoothTangent(float3, float3, float)
      • GetAutoSmoothTangent(float3, float3, float3, float)
      • GetBounds<T>(T)
      • GetBounds<T>(T, float4x4)
      • GetCatmullRomTangent(float3, float3)
      • GetCurveCount<T>(T)
      • GetNearestPoint<T>(T, float3, out float3, out float, int, int)
      • GetNearestPoint<T>(T, Ray, out float3, out float, int, int)
      • GetNormalizedInterpolation<T>(T, float, PathIndexUnit)
      • GetPointAtLinearDistance<T>(T, float, float, out float)
      • GetSubdivisionCount(float, int)
      • JoinSplinesOnKnots(ISplineContainer, SplineKnotIndex, SplineKnotIndex)
      • LinkKnots<T>(T, SplineKnotIndex, SplineKnotIndex)
      • NextIndex<T>(T, int)
      • Next<T>(T, int)
      • PreviousIndex<T>(T, int)
      • Previous<T>(T, int)
      • ReducePoints<T>(T, List<float3>, float)
      • ReducePoints<T>(T, float)
      • RemoveSplineAt<T>(T, int)
      • RemoveSpline<T>(T, Spline)
      • ReorderSpline<T>(T, int, int)
      • ReverseFlow(ISplineContainer, int)
      • ReverseFlow(Spline)
      • ReverseFlow(SplineInfo)
      • SetLinkedKnotPosition<T>(T, SplineKnotIndex)
      • SetPivot(SplineContainer, Vector3)
      • SplineToCurveT<T>(T, float, out float)
      • SplitSplineOnKnot(ISplineContainer, SplineKnotIndex)
      • UnlinkKnots<T>(T, IReadOnlyList<SplineKnotIndex>)
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)