Thank you, Unity, for getting rid of one of my biggest annoyances.
In version 2.6, this code for arrays would not work properly. In 3.0, it now does!
var myArray: Array;
myArray = [["A-zero", "A-one", "A-two", "A-three"],
["B-zero", "B-one", "B-two", "B-three"]];
function Start () {
Debug.Log (myArray[1][2]); //returns "B-two"
myArray.push(["C-zero", "C-one", "C-two", "C-three"]);
Debug.Log (myArray[2][0]); //returns "C-zero"
}
Hurrah!
Eric5h5
2
Unfortunately, neither
var foo = new int[10,10];
nor
var foo = new int[10][];
work yet in Unityscript, which is one of the main things I was hoping for in 3.0 as far as Unityscript improvements go.
–Eric
No, but this works:
var foo: Array = [10,10];
Is that different than what you were trying to accomplish with your code?
Eric5h5
4
Yes, that’s only assigning two values to a 1D array, it’s not creating a 2D array. Also, Arrays are terribly slow compared to built-in types.
–Eric