How to make a Jagged Array global?

I just found out in my last question that I can only define / initialize a jagged array in a function.

I need to be able to make a jagged array exposed globally though!

Unity doesn’t seem to like this:

var my JaggedArray : int[][];

I throws errors at me when I write that, but it is the only way I see to expose it globally!

Please help. This is the final piece I need to get what I want up and running!

Thanks! - YA

Unityscript doesn’t have the syntax required to explicitly define the type of a jagged array. If the array is not actually jagged, you can use a 2D array:

var myArray : int[,];

Otherwise you can make a List of int arrays.

var myArray : List.< int[] >;

Another possibility would be to define a jagged array implicitly using dummy values just to get the type, then assign actual values elsewhere as necessary.

var myArray = [[1]];

function Start () {
    myArray = [[1, 2, 3], [4, 5], [6], [7, 8, 9]];