Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Creating custom plane mesh - Why it's flipped?

$
0
0
I am making a custom mesh, a Plane, simply for educational purposes. The mesh is created correct but it's facing downwards (-Y Global), if I want to see it correct then I will have to rotate the GameObject 180 degrees so it's facing upwards (Y Global), which is bad. I don't want to rotate it. Do you know how can I create it correctly right from the start? In case you're interested to know here's the snippet. public static void Test() { GameObject go = new GameObject("Test"); MeshRenderer mr = go.AddComponent(); mr.sharedMaterial = new Material(Shader.Find("Diffuse")); MeshFilter mf = go.AddComponent(); Mesh m = new Mesh(); m.name = "TestMesh"; m.vertices = new Vector3[] { new Vector3(-1, 0, -1), new Vector3(1, 0, -1), new Vector3(1, 0, 1), new Vector3(-1, 0, 1) }; m.triangles = new int[] { 0, 1, 2, 0, 2, 3 }; m.RecalculateNormals(); m.RecalculateBounds(); mf.sharedMesh = m; }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>