Utility class that abstracts away the type erasure involved in adding a surface to an ArrayMesh.
Usage example:
using var surfaceBuilder = new ArrayMeshSurfaceBuilder();
var surface = new ArrayMeshSurfaceBuilder.Surface();
surface.Vertices =
[
new ArrayMeshSurfaceBuilder.Surface.Vertex(
Position: Vector3.Left,
Normal: Vector3.Back,
Color: Color.FromHtml("#ff0000"),
Uv: new Vector2(x: 0f, y: 0.5f)),
new ArrayMeshSurfaceBuilder.Surface.Vertex(
Position: Vector3.Right,
Normal: Vector3.Back,
Color: Color.FromHtml("#ffff00"),
Uv: new Vector2(x: 1f, y: 0.5f)),
new ArrayMeshSurfaceBuilder.Surface.Vertex(
Position: Vector3.Up,
Normal: Vector3.Back,
Color: Color.FromHtml("#00ff00"),
Uv: new Vector2(x: 0.5f, y: 0f)),
new ArrayMeshSurfaceBuilder.Surface.Vertex(
Position: Vector3.Down,
Normal: Vector3.Back,
Color: Color.FromHtml("#00ffff"),
Uv: new Vector2(x: 0.5f, y: 1f))
];
surface.Triangles =
[
new ArrayMeshSurfaceBuilder.Surface.Triangle(
Index0: 0,
Index1: 1,
Index2: 2),
new ArrayMeshSurfaceBuilder.Surface.Triangle(
Index0: 0,
Index1: 3,
Index2: 1),
];
surface.Name = "DemoSurface";
surface.Material = someMaterial;
surfaceBuilder.Surfaces = [surface];
surfaceBuilder.AddSurfacesToMesh(arrayMesh);