The Unity reference is great

This morning I was thinking to myself, “I wonder if you can create models dynamically in Unity in order to develop a game with procedural assets”. A quick search led me to Unity’s reference page for the Mesh object, and to my surprise, this is the description of the object:

A class that allows creating or modifying meshes from scripts.

Meshes contain vertices and multiple triangle arrays. See the Procedural example project for examples of using the mesh interface.

The triangle arrays are simply indices into the vertex arrays; three indices for each triangle.

For every vertex there can be a normal, two texture coordinates, color and tangent. These are optional though and can be removed at will. All vertex information is stored in separate arrays of the same size, so if your mesh has 10 vertices, you would also have 10-size arrays for normals and other attributes.

And then it delves into code examples of the three most common tasks one would use a Mesh for (building a new mesh, modifying vertices of a mesh, and replacing mesh triangles). It’s simple and short, but it probably answers many of the questions that brought a developer to that particular reference in the first place. It’s not a full tutorial – and it doesn’t have to be. In fact, in many cases, just reading a short snippet of code is enough to understand the whole deal behind a class, method, or property.

Contrast this to many of the platform and framework references that are out there that simply list properties and methods while stating the obvious. When you write your documentation to human eyes, and you want to be helpful, you end up with something like what Unity has done.

One response

Comments are closed.