getting every object in the scene

is there a way to get every object in the scene (including the inactive ones) through an editor/EditorWindow script.

I have been able to get all of the active Objects in the scene through

Object.FindObjectsOfType(typeof(GameObject)) as GameObject[];

but this will only ever return active GameObjects.

maybe if I could externally edit the selection.objects (storing current, selecting all, grabbing all the GameObjects in the array, and then resetting it to what it was), but this requires knowing how to get a hold of all the objects in the scene to add them to the array.

I think the better leading question is does anyone know how the engine gets all objects in the scene for say select all?

// get root objects in scene
List rootObjects = new List();
Scene scene = SceneManager.GetActiveScene();
scene.GetRootGameObjects( rootObjects );

 // iterate root objects and do something
 for (int i = 0; i < rootObjects.Count; ++i)
 {
     GameObject gameObject = rootObjects[ i ];
     gameObject.DoSomething();
 }

You can get every GameObject in the Scene by Resources.FindObjectsOfTypeAll(typeof(GameObject));.

However, that returns each and every GameObject in the scene, including hidden GameObjects used by Unity, such as the SceneCamera and PreviewCameras …

You can emulate the “Select All” behaviour with the following method:

	private void FindAll(){
		Object[] tempList = Resources.FindObjectsOfTypeAll(typeof(GameObject));
		List<GameObject> realList = new List<GameObject>();
		GameObject temp;
		
		foreach(Object obj in tempList){
			if(obj is GameObject){
				temp = (GameObject)obj;
				if(temp.hideFlags == HideFlags.None)
				    realList.Add((GameObject)obj);
			}
		}
		Selection.objects = realList.ToArray();
	}