Type UnityEngine.Transform[]' does not contain a definition for Add’ and no extension method Add' of type UnityEngine.Transform’ could be found (are you missing a using directive or an assembly reference?)
I’m getting error when I try to add spawn to array
using UnityEngine;
using System.Collections;
public class SpawnController : MonoBehaviour
{
private Transform[] spawnsList;
private int numberOfSpawns;
public GameObject prefab;
public int noPrefabsToSpawn;
void Awake ()
{
numberOfSpawns = transform.childCount;
spawnsList = new Transform[numberOfSpawns];
GameObject container = GameObject.Find("SpawnContainer");
foreach (Transform spawn in container.transform)
{
// add the spawn to the array
spawnsList.Add(spawn);
}
}
}