I created a script that instantiate a variety of different prefabs (also can instantiate more than one of the same prefab) that becomes a child of a parent (gameobject) I called slot. Once spawn each prefab has a set transformation position to a certain area, so say if I wanted my script to spawn in 3 of the same prefab (say prefab1) in to my scene, all three prefab1 would have the same transform position (it would be layered on top of each other) and also would be a child to the slot. But say if I spawn in 4 of prefab2 then prefab2 would have a different start position compared to prefab1, but is set under the same parent as prefab1...hope I'm making sense! What I want to do: is there a way to setactive false all instantiated prefabs but leave one of all the different prefabs that was spawn, for instance:
I want to setactive false all of the prefab1 and prefab2 within this black box I drew above the image and leave the one prefab1 & prefab 2 setactive to true, if the prefab1/prefab2 is deleted by collision then I would like the next prefab1/prefab2 to be setactive to true and so on. Again I hope I'm making sense... this is my code for spawning in my prefabs:
void Update () {
for (int x = 0; x < slotController; x++) {
var item = Instantiate (ItemPrefab) as GameObject;
itemPrefab.transform.position = transform.position;
itemPrefab.transform.SetParent (slot.transform);
itemPrefab.SetActive (true);
if (slot.childCount < 0) {
slotHolder.SetActive (false);
}
}
}