Best way to keep track of inactive GameObjects?

I have a lot of GUI-elements that get inactivated and activated. Annoyingly though, you can’t find disabled objects with GameObjects.Find(“name”), so I need another way to handle this.

Resources.FindObjectsOfTypeAll() might do the job. There are issues to be careful of when using this method. I’d be tempted to avoid using this call and just keep an array of the object myself. Depending on the nature of the game object, there might be other ways of solving your problem as well (like turning off rendering rather than disabling)

From the reference on FindObjectsOfTypeAll():

*This function can return any type of Unity object that is loaded, including game objects, prefabs, materials, meshes, textures, etc. It will also list internal stuff, therefore please be extra careful the way you handle the returned objects. Contrary to Object.FindObjectsOfType this function will also list disabled objects.

Please note that this function is very slow and is not recommended to be used every frame.*