I’ve created a simple cube primitive and I’d like to individually change the colors of the faces ar runtime. I tried the following, but in just came out black.
// create a test cube
m_object = GameObject.CreatePrimitive(PrimitiveType.Cube);
m_object.AddComponent("cube");
m_object.transform.position = new Vector3(0, 0, 0);
m_object.transform.eulerAngles = new Vector3(60, 0, 45);
Color[] colors = new Color[1];
colors[0] = Color.red;
Cubemap map = new Cubemap(128, TextureFormat.ARGB32, false);
map.SetPixels(colors, CubemapFace.NegativeX);
map.SetPixels(colors, CubemapFace.NegativeY);
map.SetPixels(colors, CubemapFace.NegativeZ);
map.SetPixels(colors, CubemapFace.PositiveX);
map.SetPixels(colors, CubemapFace.PositiveY);
map.SetPixels(colors, CubemapFace.PositiveZ);
m_object.renderer.material.SetTexture("_MainTex", map);
What’s the easiest way to accomplish this?