I have been working in Unity 2D and this problem is giving me the biggest headache.
My code is as follows:
Mesh m_mesh;
void Start () {
m_mesh = new Mesh();
GetComponentInChildren<MeshFilter>().mesh
= m_mesh;
m_mesh.vertices = new Vector3[] { transform.position, new Vector3(1, 1, 0), new Vector3(1, -1, 0) };
m_mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1) };
m_mesh.triangles = new int[] { 0, 2, 1 }; }
This script is on an Empty GameObject with an empty child GameObject that has both a MeshRenderer and MeshFilter on it. It is not a render issue or a normal issue because when I start play mode, a Mesh does get put into the MeshFilter on the child, but it is a completely blank mesh. There are no vertices and no triangles in it whatsoever.
The code is as simple as I have been able to reduce it to, and I still cannot see what is wrong. The mesh just simply seems to not be generating. Any help would be much appreciated.