Multidimensional .net array problem

i’m quite new with unity and ran into a problem with multidimensional .net arrays (unityscript).

var myArray : byte[,];  
myArray = new byte[5,5];

I get the compiler error ArgumentException: not a widening conversion
Can someone explain to me, whats wrong here?


the problem only seems to occur when using byte as variabletype. Int, String and double work fine and compile without an error.

I compiled that code and I didn’t get an error, but it does give that error at runtime.

If you try assigning a larger value than 255 to a byte you will get an error, also when you’re using ints or larger will have to cast to byte.

Since there is no casting operator in UnityScript, here’s what you can do:

var chunkArray : byte[,] = new byte[5,5];  //declare and initialize array  
var bt:byte = 1; //cast to byte
chunkArray[0,0] = bt; //assign value