Table of Contents

Class ProceduralMeshBuilder

Namespace
S1MAPI.ProceduralMesh
Assembly
S1MAPI_Mono.dll

High-level fluent builder for creating procedural meshes. Provides a chainable API for constructing meshes from basic shapes.

public sealed class ProceduralMeshBuilder
Inheritance
ProceduralMeshBuilder
Inherited Members

Remarks

Use the builder pattern to add shapes, configure materials, then call Build() to create the final mesh. Unity automatically handles cleanup on scene unload and application quit.

Constructors

ProceduralMeshBuilder(string)

Create a new procedural mesh builder.

public ProceduralMeshBuilder(string name)

Parameters

name string

Name for the generated mesh

Exceptions

ArgumentNullException

Thrown when name is null or empty

Methods

AddBox(Vector3, Vector3)

Add a box (cube) to the mesh.

public ProceduralMeshBuilder AddBox(Vector3 center, Vector3 size)

Parameters

center Vector3

Center position of the box

size Vector3

Size of the box

Returns

ProceduralMeshBuilder

This builder for method chaining

AddCapsule(Vector3, Vector3, float)

Add a capsule to the mesh.

public ProceduralMeshBuilder AddCapsule(Vector3 start, Vector3 end, float radius)

Parameters

start Vector3

Start position (bottom)

end Vector3

End position (top)

radius float

Radius of the capsule

Returns

ProceduralMeshBuilder

This builder for method chaining

AddCylinder(Vector3, Vector3, float, int)

Add a cylinder to the mesh.

public ProceduralMeshBuilder AddCylinder(Vector3 start, Vector3 end, float radius, int segments = 12)

Parameters

start Vector3

Start position (bottom center)

end Vector3

End position (top center)

radius float

Radius of the cylinder

segments int

Number of radial segments

Returns

ProceduralMeshBuilder

This builder for method chaining

AddSphere(Vector3, float, int)

Add a sphere to the mesh.

public ProceduralMeshBuilder AddSphere(Vector3 center, float radius, int subdivisions = 8)

Parameters

center Vector3

Center position of the sphere

radius float

Radius of the sphere

subdivisions int

Number of subdivisions (higher = smoother)

Returns

ProceduralMeshBuilder

This builder for method chaining

ApplyFlatShading()

Apply flat shading when building the mesh. Creates a low-poly aesthetic with hard edges.

public ProceduralMeshBuilder ApplyFlatShading()

Returns

ProceduralMeshBuilder

This builder for method chaining

Build()

Build a GameObject with the mesh and material applied.

public GameObject Build()

Returns

GameObject

The created GameObject with mesh components

BuildMesh()

Build the mesh and return it.

public Mesh BuildMesh()

Returns

Mesh

The constructed mesh

SetColor(Color)

Set a solid color for the mesh (creates a material internally).

public ProceduralMeshBuilder SetColor(Color color)

Parameters

color Color

The color to apply

Returns

ProceduralMeshBuilder

This builder for method chaining

SetMaterial(Material)

Set the material for the generated mesh.

public ProceduralMeshBuilder SetMaterial(Material material)

Parameters

material Material

The material to apply

Returns

ProceduralMeshBuilder

This builder for method chaining