I tried rendering a cube with Graphics.DrawMesh on Unity 4.3, but nothing seems to happen. I have an empty scene with a camera looking at the origin. The following script is attached to the camera:
using UnityEngine;
public class DrawMesh : MonoBehaviour
{ /* 5_ _ _6
/| /|
1/_|_ 2/ |
| 4|_ _|_|7
| / | /
|/_ _ _|/
0 3 */
Mesh mesh;
void Start() {
mesh = new Mesh();
Vector3[] vertices = new Vector3[] {
new Vector3(-1, -1, -1),
new Vector3(-1, +1, -1),
new Vector3(+1, +1, -1),
new Vector3(+1, -1, -1),
new Vector3(-1, -1, +1),
new Vector3(-1, +1, +1),
new Vector3(+1, +1, +1),
new Vector3(+1, -1, +1)};
int[] triangles = new int[] {
0, 1, 2, 2, 3, 0,
1, 5, 6, 6, 2, 1,
3, 2, 6, 6, 7, 3,
4, 5, 1, 1, 0, 4,
0, 3, 7, 7, 4, 0,
7, 6, 5, 5, 4, 7};
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
void Update () {
Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity);
}
}
What am I doing wrong?
[18872-drawmesttest.zip|18872]

