The documentation on the [Mesh][1] functions is pretty thorough. Point 1 has a code example to build a mesh from scratch:
1. Building a mesh from scratch: should always be done in the following order: 1) assign vertices 2) assign triangles
var newVertices : Vector3[];
var newUV : Vector2[];
var newTriangles : int[];
function Start () {
var mesh : Mesh = new Mesh ();
GetComponent(MeshFilter).mesh = mesh;
mesh.vertices = newVertices;
mesh.uv = newUV;
mesh.triangles = newTriangles;
}
[1]: http://unity3d.com/support/documentation/ScriptReference/Mesh.html
↧