I'm trying to render some points in unity but can't get it working… here's my code. I think maybe it has something to do with the shader I'm using? Not sure tough
m_ptOb = new GameObject();
MeshRenderer mr = m_ptOb.AddComponent<MeshRenderer>();
mr.sharedMaterial = new Material(Shader.Find("Unlit/Color"));
MeshFilter mf = gameObject.AddComponent<MeshFilter>();
Mesh mesh = new Mesh();
Vector3[] vertices = new Vector3[m_pt.Length];
int[] indices = new int[m_pt.Length];
int[] tris = new int[m_pt.Length / 3];
Color[] cl = new Color[m_pt.Length];
for (int i = 0; i < vertices.Length; i++)
{
vertices[i] = new Vector3(Random.value, Random.value, Random.value);
indices[i] = i;
cl[i] = Color.white;
}
for(int i = 0; i < tris.Length; i++)
{
tris[i] = i;
}
mesh.vertices = vertices;
mesh.colors = cl;
mesh.SetIndices(indices, MeshTopology.Points, 0);
mesh.triangles = tris;
mesh.RecalculateBounds();
mf.mesh = mesh;