Add to .net Arrays

How would you add GameObjects to a .Net array?

var Whatever : GameObject[];

The Whatever.Add(); doesn’t seem to work with statically typed and in this case I don’t want to use dynamically typed.

1 Answer

1

Native arrays can't be resized dynamically. They have to be recreated with the new size and you have to copy the old elements into the new array.

Usually you would use a container class for such a task.

Use generic List:

var whatever : List.<GameObject>;

whatever = new List.<GameObject>();

whatever.Add(gameObject);

Awesome, Thanks