find inactive gameobject by tag in unity3d

Things that can find inactive gameObjects :

transform.Find() or transform.FindChild()
transform.GetComponentsInChildren<Component>(true)

Resources.FindObjectsOfTypeAll<Component>()

FindObjectsOfTypeAll does find inactive, it just may also find prefabs and things you are not looking for, so you have to be careful.


After some research it seems that there is no way to find an inactive gameobject by tag.

solutions exist however to access inactive gameobjects:

1 - Store inactive game objects in an array if you need to reactivate them afterwards (only applies to game objects inactivated at runtime).

2 - Do not deactivate game object, simply deactivate the components you want inactive. If you wish to make the object disappear, deactivate the renderer. If it is a specific script, deactivate that script, etc.

This solution will allow you to still find a game object by its tag name.

Tags:

C#

Unity3D