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(); 

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):

rather than “Add” try “Push”


for a list, you could say:

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