I have a function that requires input in the form of an array, but I want to be able to specify which array is passed to the function. I have initialized several arrays (builtin, if that’s relevant) and stored them inside another array (JS Array).
Here is a simplified example of what I’ve got:
var numbers = new String[3];
numbers[0] = "1";
numbers[1] = "2";
numbers[2] = "3";
var letters = new String[3];
letters[0] = "1";
letters[1] = "2";
letters[2] = "3";
var names : Array = new Array(
numbers,
letters
);
function Evaluate(input) {
for (var each in input) {
print (each);
}
}
function Start () {
Evaluate(names[1]);
print(names[0].Length);
}
When I run the script, the Evaluate function works as expected. However, the print statement throws the following error: “Assets/NewBehaviourScript.js(27,24): BCE0019: ‘Length’ is not a member of ‘Object’.”
I’m guessing that I have to let Unity know that the contents of array “names” are all of type “builtin array”, and that they DO support to .Length method. I’ve gotta supply the type somehow. Where? How?
Any explanation would be very helpful, because I’ve been trying to figure this out forever… with absolutely no success.
uncapitalize
– Benproductions1Lengthand you should be fineGood thought! Unfortunately, I had already tried both capitalizations, receiving the same result regardless. (More detailed comment below) Any other possibilities?
– Flame_of_Endil