How to find inactive objects using GameObject.Find(” “) in Unity3D?

Well, using GameObject.Find(...) will never return any inactive objects. As the documentation states:

This function only returns active gameobjects.

Even if you could, you’d want to keep these costly calls to a minimum.

There are “tricks” to finding inactive GameObjects, such as using a Resources.FindObjectsOfTypeAll(Type type) call (though that should be used with extreme caution).

But your best bet is writing your own management code. This can be a simple class holding a list of objects that you might want to find and use at some point. You can put your object into it on first load. Or perhaps add/remove them on becoming active or inactive. Whatever your particular scenario needs.

Leave a Comment