- Home /
Question by
dm721 · Oct 23, 2017 at 04:03 AM ·
arrayscolor change
Random Color Array material turns white
Not sure why this doesn't work. Probably something stupid I am overlooking. Turns the objects color to white when it should be one of these 5
public class ChooseColor : MonoBehaviour {
Color[] colors = new Color[5];
// Use this for initialization
void Start() {
colors[0] = new Color(110, 130, 191);
colors[1] = new Color(131, 179, 162);
colors[2] = new Color(225, 225, 140);
colors[3] = new Color(190, 144, 146);
colors[4] = new Color(190, 182, 225);
GetComponent<Renderer>().material.color = colors[Random.Range(0, colors.Length)];
}
}
Comment
Answer by adipatil3517 · Oct 23, 2017 at 04:59 AM
i am not sure what you are trying to do but check if material color changes or not in inspector i think you are not getting component that is why color is not changing.check whether you are getting component or not