2 and 3 dimensional Arrays

I read the API for the Array class and noticed that Unity does not support Arrays within Arrays. Is there any workaround for this? Not supporting 2 and 3 dimensional arrays in a 3D environment makes Unity much less powerful for what I am needing to program.

What language are you programming in?

Unity does support arrays in arrays, and doesn’t need any workarounds. However, real 2D/3D arrays are better, and that’s also supported. If using JS, see here. Don’t bother with the Array class in any case.

–Eric

Thank you! This will be very helpful.

Unity 3.2 has support for proper multidimensional arrays in JS now, so no need for workarounds anymore.

–Eric

How are these done? I am using eric’s vectrosity and wish to make a growing list of lines the user can draw.

I don’t think you need a multi-dimensional array for that, just a List sounds fine:

var listOfLines = new List.<VectorLine>();

But if you did use a 2D array (10 x 10 in this case):

var array2D = new VectorLine[10, 10];

Those sorts of arrays aren’t resizable though.

–Eric