Skip to main content
100%

Gist 38e049a8e58056d8542d9ee67c7957e0

✓ Published0🌍 Public
Aandybak
Last edited Sep 24, 2023
Created on Sep 24, 2023

This example shows a simple 3D pyramid whose apex moves upward or downward when the user presses the arrow keys. It demonstrates how to create and update a mesh at runtime using Unity’s Mesh API, with vertex data stored in a `NativeArray<float3>` for efficient modification. The code sets up a triangle-based submesh, defines vertex and index buffers via `SetVertexBufferParams` and `SetIndexBufferParams`, and redraws the mesh each frame with `Graphics.DrawMesh`. The pyramid is rendered using a provided material, and only the top vertex’s position is altered in response to input.

AI-generated description

Similar vizzes