docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SplineMesh

    Static functions for extruding meshes along Spline paths. Use this class to build extruded meshes from code, or SplineExtrude for a pre-built Component that can be attached to any GameObject with a SplineContainer.

    Inheritance
    object
    SplineMesh
    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 SplineMesh

    Methods

    Extrude<T>(IReadOnlyList<T>, Mesh, float, int, float, bool, float2)

    Extrude a mesh along a list of splines in a tube-like shape.

    Declaration
    public static void Extrude<T>(IReadOnlyList<T> splines, Mesh mesh, float radius, int sides, float segmentsPerUnit, bool capped, float2 range) where T : ISpline
    Parameters
    Type Name Description
    IReadOnlyList<T> splines

    The splines to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    float radius

    The radius of the extruded mesh.

    int sides

    How many sides make up the radius of the mesh.

    float segmentsPerUnit

    The number of edge loops that comprise the length of one unit of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    float2 range

    The section of the Spline to extrude. This value expects a normalized interpolation start and end. I.e., [0,1] is the entire Spline, whereas [.5, 1] is the last half of the Spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    Extrude<T>(T, Mesh, float, int, int, bool)

    Extrude a mesh along a spline in a tube-like shape.

    Declaration
    public static void Extrude<T>(T spline, Mesh mesh, float radius, int sides, int segments, bool capped = true) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    float radius

    The radius of the extruded mesh.

    int sides

    How many sides make up the radius of the mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    Extrude<T>(T, Mesh, float, int, int, bool, float2)

    Extrude a mesh along a spline in a tube-like shape.

    Declaration
    public static void Extrude<T>(T spline, Mesh mesh, float radius, int sides, int segments, bool capped, float2 range) where T : ISpline
    Parameters
    Type Name Description
    T spline

    The spline to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    float radius

    The radius of the extruded mesh.

    int sides

    How many sides make up the radius of the mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    float2 range

    The section of the Spline to extrude. This value expects a normalized interpolation start and end. I.e., [0,1] is the entire Spline, whereas [.5, 1] is the last half of the Spline.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    Extrude<T, K>(T, Mesh, float, int, bool, float2, K)

    Extrude a mesh along a spline following a shape template.

    Declaration
    public static void Extrude<T, K>(T spline, Mesh mesh, float radius, int segments, bool capped, float2 range, K shape) where T : ISpline where K : IExtrudeShape
    Parameters
    Type Name Description
    T spline

    The spline to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    float radius

    The radius of the extruded mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    float2 range

    The section of the Spline to extrude. This value expects a normalized interpolation start and end. I.e., [0,1] is the entire Spline, whereas [.5, 1] is the last half of the Spline.

    K shape

    The IExtrudeShape object defines the outline path of each segment.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    K

    A type implementing IExtrudeShape.

    Extrude<T, K>(T, Mesh, float, int, bool, K)

    Extrude a mesh along a spline with a customised shape.

    Declaration
    public static void Extrude<T, K>(T spline, Mesh mesh, float radius, int segments, bool capped, K shape) where T : ISpline where K : IExtrudeShape
    Parameters
    Type Name Description
    T spline

    The spline to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    float radius

    The radius of the extruded mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    K shape

    The IExtrudeShape object defines the outline path of each segment.

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    K

    A type implementing IExtrudeShape.

    Extrude<T, K>(T, Mesh, ExtrudeSettings<K>)

    Extrude a mesh along a spline following a shape template.

    Declaration
    public static bool Extrude<T, K>(T spline, Mesh mesh, ExtrudeSettings<K> settings) where T : ISpline where K : IExtrudeShape
    Parameters
    Type Name Description
    T spline

    The spline to extrude.

    Mesh mesh

    A mesh that will be cleared and filled with vertex data for the shape.

    ExtrudeSettings<K> settings

    The ExtrudeSettings<T> parameters used when creating mesh geometry.

    Returns
    Type Description
    bool

    Returns true if mesh was created, or false if the settings configuration resulted in an invalid state (ex, too few vertices).

    Type Parameters
    Name Description
    T

    A type implementing ISpline.

    K

    A type implementing IExtrudeShape.

    Extrude<TSplineType, TVertexType, TIndexType>(TSplineType, NativeArray<TVertexType>, NativeArray<TIndexType>, float, int, int, bool, float2)

    Extrude a mesh along a spline in a tube-like shape.

    Declaration
    public static void Extrude<TSplineType, TVertexType, TIndexType>(TSplineType spline, NativeArray<TVertexType> vertices, NativeArray<TIndexType> indices, float radius, int sides, int segments, bool capped, float2 range) where TSplineType : ISpline where TVertexType : struct, SplineMesh.ISplineVertexData where TIndexType : struct
    Parameters
    Type Name Description
    TSplineType spline

    The spline to extrude.

    NativeArray<TVertexType> vertices

    A pre-allocated buffer of vertex data.

    NativeArray<TIndexType> indices

    A pre-allocated index buffer. Must be of type UInt16 or UInt32.

    float radius

    The radius of the extruded mesh.

    int sides

    How many sides make up the radius of the mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    float2 range

    The section of the Spline to extrude. This value expects a normalized interpolation start and end. I.e., [0,1] is the entire Spline, whereas [.5, 1] is the last half of the Spline.

    Type Parameters
    Name Description
    TSplineType

    A type implementing ISpline.

    TVertexType

    A type implementing ISplineVertexData.

    TIndexType

    The mesh index format. Must be UInt16 or UInt32.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    An out of range exception is thrown if the vertex or index buffer lengths do not match the expected size. Use GetVertexAndIndexCount(int, int, bool, bool, bool, out int, out int) to calculate the expected buffer sizes.

    ArgumentException

    An argument exception is thrown if {TIndexType} is not UInt16 or UInt32.

    GetVertexAndIndexCount(int, int, bool, bool, bool, out int, out int)

    Calculate the vertex and index count required for an extruded mesh. Use this method to allocate attribute and index buffers for use with Extrude.

    Declaration
    public static bool GetVertexAndIndexCount(int sides, int segments, bool capped, bool closed, bool closeRing, out int vertexCount, out int indexCount)
    Parameters
    Type Name Description
    int sides

    How many sides make up the radius of the mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    bool closed

    Whether the extruded mesh is closed or open. This can be separate from the Spline.Closed value.

    bool closeRing

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

    int vertexCount

    The number of vertices required for an extruded mesh using the provided settings.

    int indexCount

    The number of indices required for an extruded mesh using the provided settings.

    Returns
    Type Description
    bool

    Returns true if the computed vertex count exceeds 3 and the computed index count exceeds 5.

    GetVertexAndIndexCount(int, int, bool, bool, Vector2, out int, out int)

    Calculate the vertex and index count required for an extruded mesh. Use this method to allocate attribute and index buffers for use with Extrude.

    Declaration
    public static void GetVertexAndIndexCount(int sides, int segments, bool capped, bool closed, Vector2 range, out int vertexCount, out int indexCount)
    Parameters
    Type Name Description
    int sides

    How many sides make up the radius of the mesh.

    int segments

    How many sections compose the length of the mesh.

    bool capped

    Whether the start and end of the mesh is filled. This setting is ignored when spline is closed.

    bool closed

    Whether the extruded mesh is closed or open. This can be separate from the Spline.Closed value.

    Vector2 range

    The section of the Spline to extrude. This value expects a normalized interpolation start and end. I.e., [0,1] is the entire Spline, whereas [.5, 1] is the last half of the Spline.

    int vertexCount

    The number of vertices required for an extruded mesh using the provided settings.

    int indexCount

    The number of indices required for an extruded mesh using the provided settings.

    In This Article
    Back to top
    Copyright © 2024 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)