|
I get an error ('RemoveAt' is not a member of (UnityEngine.GameObject) if I do this:
What is the syntax to add or remove a GameObject from a array of GameObjects? This is in Javascript.
(comments are locked)
|
|
You're getting this error because there are more than one kind of array which you can use in Unity, and they each have different functions and features. There are built-in arrays, which are fixed-size, and don't have functions which would change their length (like Add, Remove). Built-in arrays are declared using square brackets. There is also Unity's Javascript Array class, which does have these features - however none of Unity's functions which return collections of objects return Javascript Array objects, they all return built-in arrays! (there are also many other array-like types available to use, but that's a different topic!) So if you need to add or remove objects from your collection, generally you would retrieve the built-in array from your unity function, and convert it to a Javascript Array immediately after, like this: Ok, got it. Thank you!
May 10 '10 at 04:29 PM
Zootie
(comments are locked)
|
|
That's not possible, but you can convert built-in arrays to dynamic arrays like this:
and back to static arrays like this:
(comments are locked)
|

Format code by selecting it and hitting the code button.