Class SplineMesh
Utility methods for creating and working with meshes.
Inherited Members
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<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, Vector2, 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, 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. |