find all objects in a scene

Is it possible to find all objects in a scene,
or better yet find a gameobject with a missing script?

My problem is that I have a gameobject with a misscing script causing an error warning,
but the missing script activated the hideflag hideininspector so I cannot delete this gameobject because I cannot select it.
If I can somehow brag the gameobject form a script I can restore its hideflags to 0 to make it visible and then delete it from the inspector :slight_smile:

ok how about FindObjectsOfType(Transform);

all objects have a transform, right?

oh, that won’t work for inactive objects though, so maybe not…

Edit: glad it worked, wasn’t sure myself!

If the object has a unique tag, just iterate through all the objects with that tag. Same goes for being on a certain layer, alone. If there is some script that it -does- have that it’s not missing, that no other object has, that would work as well. You just need to find some defining feature about what it does/doesn’t have that would make it unique, and iterate through all the game objects with that property/those properties, until you find it.

Alternatively, you could look in the hierarchy view, unless I’m misunderstanding something about “hidden” objects…

[Edit] I apparently misunderstood what hideflags were. To do what you’re trying to do, simply use the following code in a monobehaviour:

GameObject[] gameObjs = FindObjectsOfType(typeof(GameObject)) as GameObject[];
foreach(GameObject go in gameObjs)
    if(go.hideFlags == HideFlags.HideInInspector)

Just put this script in a method and call it in Start or Update or Awake or something, in a monobehaviour in your scene, and you should be set.

If you want, I can make an attempt at rewriting this in JS… but mind you I’m pretty strictly a C# programmer, for Unity :stuck_out_tongue:

to find all objects in a scene just select ur scene and press: Ctrl + a

u could try to use the hierarchy tab to try to find ur object with the missing script.