Add GameObject to Array

obj is a GameObject. I’m getting an error trying to add it to my array see below:

var myArray = new Array(); 
myArray.Add(obj);

I’ve looked all over UnityAnswers - how can I add a GameObject to an array?

It’s been asked a hundred times but none of the answers make any sense to me. if I want to use the array type above is it possible?

First of all, you shouldn’t use the Array() class… You’re better off using a 1

(if you do prefer it though, see here):

http://www.w3schools.com/js/js_obj_array.asp

rather than “Add” try “Push”

myArray.Push(obj);

for a list, you could say:

var myList = new List.<GameObject>();
myList.Add(obj);