I have been trying to figure this out for far to long and figured id ask here. I am making a music visualizer and on start it instantiates a bunch of white cubes How do i add a material to them? I have them tagged as “cubes”
Here is a pic of the code snippet, im not sure how to just show the code here yet.
public void SpawnLine()
{
visualScale = new float[amnVisual];
visualList = new Transform[amnVisual];
for (int i = 0; i < amnVisual; i++)
{
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube) as GameObject;
visualList = go.transform;
visualList_.position = Vector3.right * i;_
go.tag = “cubes”;
// This changes the color, but not what im after.
// go.GetComponent().material.color = Color.green;
}
}