GameObject.Find() only returns active objects.
for unactive objects, use this:
Resources.FindObjectsOfTypeAll(typeof(YOURTYPEHERE));
so, lets say you want to find all of a certain tag, that aren't active:
foreach (GameObject obj in Resources.FindObjectsOfTypeAll(typeof(GameObject))) {
if (obj.tag == "Player" && !obj.activeSelf) { //any if statement here
print(obj.name + " is inactive, and has a tag of 'Player'.");
}
}
I have confirmed this works in 5.6+, and 2017.1+
↧