- Home /
Question by
willvascoOU · Apr 06, 2018 at 01:15 AM ·
prefab-instance
Multiple instances of script running, only most recent one works
I'm spawning delivery boxes from a menu and displaying 'ghosts' for places the delivery box can be placed. The script to find the appropriate ghosts to display them is as follows
void DisplayGhosts() {
if (NVRReference.IsAttached == true) {
foreach (GameObject ghost in RoomController.Instance.ghostList) {
if (ghost.name == mySize + " Object Space") {
ghost.SetActive (true);
foreach (Transform child in ghost.transform) {
if (child.gameObject.name == myObjectName + " Ghost") {
child.gameObject.SetActive (true);
print (myObjectName);
} else {
child.gameObject.SetActive (false);
print (child.gameObject.name);
}
}
}
}
} else {
foreach (GameObject ghost in RoomController.Instance.ghostList) {
ghost.SetActive (false);
}
}
}
We have put prints in every block of this script and every block is running on every object as it is supposed to, but for some reason only the most recently spawned box is activating the ghosts. We know that all of the boxes are getting reference to the ghosts, but for some reason only the most reason one is actually activating them, and no error is being thrown. Thoughts?
Comment