Quantcast
Channel: Answers for "GameObject.Find() work on inactive objects"
Viewing all articles
Browse latest Browse all 45

Answer by Antony-Blackett

$
0
0
The solution only works if you don't rely on transform.root anywhere in your game. It also doesn't work if you need to find objects that are children of objects that don't get destroyed on load. Add a GameObject that is the root of all GameObjects in your scene. Then instead of FindObjectsOfType() use GetComponentsInChildren( typeof(Transform), true ); That should return all transforms of all GameObjects in the scene as they are all a child of the scene root, active or not. If you can't or don't want to create a scene root object then you'll need to make an array of all the root objects in your scene and all GetCompoenentsInChildren() on all of them separately.

Viewing all articles
Browse latest Browse all 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>