using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpawnObject : MonoBehaviour { public List<Transform> possiblePositions = new List<Transform>(); public List<GameObject> allThings = new List<GameObject>(); void Start() { // do something as long as objects in the array exist for (int i = possiblePositions.Count; i > 0; i--) { int rndObject = Random.Range(0, allThings.Count);// generate a number from 0 to possible objects in the list (that changes) Instantiate(allThings[rndObject], possiblePositions[0].position, Quaternion.identity);// spawn object at the 1st spawn point possiblePositions.RemoveAt(0); // remove spawn position that has been used!! allThings.RemoveAt(rndObject); // remove the spawned object that has been used!! } } }