Hi, I’m beginner on unity3d.
I’ve created mesh by using GL class with GL.QUADS mode.
There is a method, GL.Vertex3(), but not GL.Normal3(), so I can’t set normal vectors to vertices or triangles.
I’ve googled a day with keywords; ‘unity3d gl normal’, ‘unity3d gl light’, etc… but couldn’tget a solution.
How can I apply normal vectors and lights to mesh made by GL class?
Thanks for reading!
You probably want to use the Mesh class instead. You can either use a mesh created this way in a mesh filter component as usual, or use Graphics.DrawMesh.
–Eric
you can’t.
You will need to use the Mesh class
@Eric5h5, dreamora
Thank you for the replies!
But when I set new vertices or triangles to mesh, mesh.vertices didn’t change with new values.
The situation is,
private Mesh mesh = new Mesh();
void Start() {
mesh.vertices = new Vertex3[4];
mesh.vertices[0] = new Vertex3(-5, 10, -5);
mesh.vertices[1] = new Vertex3(-5, 10, -5);
mesh.vertices[2] = new Vertex3(-5, 10, -5);
mesh.vertices[0] = new Vertex3(-5, 10, -5);
print(mesh.vertices[0]);
}
Then output message is (0.0, 0.0, 0.0).
I choose GL class because of this result.
I guess, I misunderstood for using Mesh class.
Do I wrong with using Mesh class? Please give me a hint for setting vertices to mesh object.
You need to create a temporary array, fill it and then assign that array to mesh.vertices, thats cause you work with structs there, not with classes
Follow the code examples in the docs, and assign the entire array to mesh.vertices (same goes for normals, triangles, etc.). You can’t read/write individual array elements like that.
–Eric
Thanks. It works exactly!
Why don’t the document notice the importance of that?
hmm…
report it as feature request through the bug reporter so it can be done 
I agree that the relevance of what is struct, what not and the implications in such cases should be brought to broader attention as an important note or alike (div block in light yellow or alike that surrounds such relevant notes)
The document didn’t notice ‘you first assign a values into array, and next assign the array to mesh.vertices.’ …