Class CustomMeshBuilder
- Namespace
- S1MAPI.ProceduralMesh
- Assembly
- S1MAPI_Mono.dll
Simple fluent builder for creating custom meshes from scratch. Perfect for mods that need custom geometry (furniture, decorations, etc.).
public sealed class CustomMeshBuilder
- Inheritance
-
CustomMeshBuilder
- Inherited Members
Examples
var mesh = new CustomMeshBuilder("MyChair")
.AddVertex(new Vector3(0, 0, 0))
.AddVertex(new Vector3(1, 0, 0))
.AddVertex(new Vector3(0.5f, 1, 0))
.AddTriangle(0, 1, 2)
.Build();
Constructors
CustomMeshBuilder(string)
Create a new custom mesh builder.
public CustomMeshBuilder(string name)
Parameters
namestringName for the generated mesh
Methods
AddQuad(int, int, int, int)
Add a quad (two triangles) from 4 vertices.
public CustomMeshBuilder AddQuad(int v0, int v1, int v2, int v3)
Parameters
Returns
AddTriangle(int, int, int)
Add a triangle (counter-clockwise winding).
public CustomMeshBuilder AddTriangle(int v0, int v1, int v2)
Parameters
Returns
AddVertex(Vector3)
Add a single vertex.
public CustomMeshBuilder AddVertex(Vector3 vertex)
Parameters
vertexVector3
Returns
AddVertices(params Vector3[])
Add multiple vertices at once.
public CustomMeshBuilder AddVertices(params Vector3[] vertices)
Parameters
verticesVector3[]
Returns
ApplyPlanarUVs()
Set a simple planar UV based on vertex position.
public CustomMeshBuilder ApplyPlanarUVs()
Returns
ApplyPlanarUVs(Vector3, Vector3)
Apply UVs by projecting onto a plane.
public CustomMeshBuilder ApplyPlanarUVs(Vector3 up, Vector3 offset)
Parameters
upVector3offsetVector3
Returns
Build()
Build a GameObject with the mesh and material applied.
public GameObject Build()
Returns
- GameObject
Build(Transform)
Build a GameObject with the mesh and attach to a parent.
public GameObject Build(Transform parent)
Parameters
parentTransform
Returns
- GameObject
BuildMesh()
Build and return the Mesh.
public Mesh BuildMesh()
Returns
- Mesh
DontCalculateNormals()
Disable automatic normal calculation (use when providing custom normals).
public CustomMeshBuilder DontCalculateNormals()
Returns
SetColor(Color)
Set a solid color (creates material internally).
public CustomMeshBuilder SetColor(Color color)
Parameters
colorColor
Returns
SetMaterial(Material)
Set the material for this mesh.
public CustomMeshBuilder SetMaterial(Material material)
Parameters
materialMaterial
Returns
SetUVs(params Vector2[])
Add UV coordinates for each vertex (must match vertex count).
public CustomMeshBuilder SetUVs(params Vector2[] uvs)
Parameters
uvsVector2[]