GameObject cube = Cube.CreatePrimitive(Cube.CubePivotPoint.UPLEFT);
cube.GetComponent<Renderer>().material.color = Color.blue;
When i assign the color i'm getting exception on the line:
cube.GetComponent<Renderer>().material.color = Color.blue;
MissingComponentException: There is no 'Renderer' attached to the "CubeHolder" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "CubeHolder". Or your script needs to check if the component is attached before using it.
NOTE:
I am using the CUBE
class from this answer to create a cube, not the Unity's GameObject.CreatePrimitive
function.