I get the error " Array index is out of range."
What is wrong with my code?
var colorsArray = new Color[2];
function Start () {
colorsArray[0] = Color32(2,65,201,255);
colorsArray[1] = Color32(62,32,151,255);
}
I get the error " Array index is out of range."
What is wrong with my code?
var colorsArray = new Color[2];
function Start () {
colorsArray[0] = Color32(2,65,201,255);
colorsArray[1] = Color32(62,32,151,255);
}
Sounds like it’s in implicit array error happening on different color type arrays:
new color32;
check here for conversions, if color32 doesnt work, this can be a workaround:
Using pre-initialization for array and Color component:
var colorsArray:Color[] = new Color[2];
function Start () {
colorsArray[0] = Color32(2, 65, 201, 255);
colorsArray[1] = Color32(62, 32, 151, 255);
}
And check your array in Inspector, as variable ColorsArray is public. I hope that it will help you.