- Home /
GameObjects that I deactivate are reactivated immediately
When I load a scene, I'm searching for particular objects and deactivating them with the following:
GameObject[] toDeactivate = GameObject.FindGameObjectsWithTag(targetTag);
foreach (GameObject obj in toDeactivate) {
Debug.Log ("deactivating " + obj);
obj.SetActive(false);
Debug.Log ("status: " + obj.activeInHierarchy);
}
My log output shows that, in fact, objects are being found correctly, and obj.activeInHierarchy
does report false for each found and deactivated object. When I play the scene, I can see the correct objects deactivate, but they are immediately reactivated. Any ideas as to why this is happening? Any tips on rooting out the cause of this, or what is triggering the reactivation?
If they reactivate right away...try debugging after 1-2 seconds with a coroutine and see what you get.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Panel GameObject not activating 0 Answers
SetActive(true) is not working 2 Answers
Panel GameObject not activating when called from another script 1 Answer