Appending items to a gameobject array [Solved]

I can’t seem to get a game object to append to the end of a gameobject array. What am I doing wrong here?
Looking at this it looks like I’m doing it right: http://docs.unity3d.com/ScriptReference/Array.Add.html

I read in another post “Built-in arrays are not resizable and don’t have any Add functions or the like,” so if that’s the case I’m facing how would I go about appending something to the array?

#pragma strict

var newObject : GameObject;
private var objectArray : GameObject[];

function Start () {

    objectArray.Add (newObject);

}

In c# you want a List<> of items,which has a .Add() method. Not sure of the exact syntax in Js but I’m sure there’s an equivalent to a List<>. IIRC, java uses empty bracket notation for an empty list and then a .push() method to add stuff, but don’t quote me on that… Google for it a bit…

1 Like

How about objectArray.Push(newObject); if that can help ?

Generic lists are the way to go.

Thanks for the replies. I ended up going with the generic list method and it worked out well.