- Home /
How to get length of inner array in unityscript multidimesional array?
I have a multi-dimensional array (using built-in array's) in unityscript. I define it programatically like so:
var sequenceArray : Vector3[ , , ] = new Vector3[width, width, width];
I add values to it like so:
sequenceArray[x,y,z] = cubePosition;
Elsewhere in the code, I need to be a able to find the length of the inner arrays (ie the value of width), using something like the following:
sequenceArray[0].Length
But I get the error:
'Length' is not a member of 'UnityEngine.Vector3'.
I come from a JavaScript mentality, where a multidimensional array is just an array of arrays, and I think that is what is confusing me here. Is it possible to even get the length of an "inner-array" in a multidimensional built-in array? Or is there no such concept of "inner-array" when using a built-in array in Unity?
Thanks for the help.
Answer by Eric5h5 · Dec 29, 2014 at 05:48 PM
Use System.Array.GetLength. Since Unity uses Mono, all answers about functions like this can be found in the MSDN .NET docs.
I've used it in the following way:
cubeSequence.GetLength(0);
And it works great! Thanks for the help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613175124im_/https://answers.unity.com/themes/thub/images/avi.jpg)