In Unity 3D doc for accessing vertices there is a line in C#: Code (csharp): Mesh mesh = GetComponent<MeshFilter>().mesh; I have tried to access it with Mesh mesh = GetComponent("MeshFilter").mesh but it wont work. This is the way I used before to access object components. Why do I have to put <MeshFilter>() ? What is the meaning of this method ?
http://docs.unity3d.com/Documentation/Components/class-MeshFilter.html It basically renders the mesh.
You pretty much never want to use strings in GetComponent. In Unityscript you would write GetComponent(MeshFilter), which casts to MeshFilter automatically. If you wrote GetComponent("MeshFilter"), it would cast to Component, which isn't what you want. In C# you could write GetComponent(typeof(MeshFilter)) as MeshFilter, which is quite annoying, so GetComponent<MeshFilter>() is a shortcut that uses generics to do the casting. (Although it does run a tiny bit slower than manually casting, nothing to be concerned about though. But that's why you should not use the generic version of GetComponent in Unityscript, since it's slightly less efficient and in the case of Unityscript doesn't save you any typing, in fact the opposite.) --Eric