Here's how you do it.
Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
Note this can also return prefabs not just object instances in the scene so be careful when using it at edit time.
↧