what about references?

Hello!

I am quite experienced in plain c# but not in unity. I don’t understand a line in this code (from http://unity3d.com/support/documentation/ScriptReference/Mesh-vertices.html):

function Update () {
var mesh : Mesh = GetComponent(MeshFilter).mesh;
var vertices : Vector3[] = mesh.vertices;

for (var i = 0; i < vertices.Length; i++)
vertices _+= Vector3.up * Time.deltaTime;_

mesh.vertices = vertices;
mesh.RecalculateBounds();
}
Why has the vertices array to be assigned back to mesh.vertices? Is not the vertices a plain reference to mesh.vertices? I’m afraid I’m missing an important point here, could anyone help please?

The mesh has to be uploaded to the graphics card. The graphics card does not access system memory (and, likewise, your code has no access to VRAM).

var vertices : Vector3[] = mesh.vertices;

This doesn't look like it's referencing anything really. The overload is probably just an array copy instruction.