【Unity】How to get the game objects get using FindObjectsOfType in the same order as the hierarchy.
KENTO⚽️XR Engineer😎
Posted on October 29, 2022
The list get using FindObjectsOfType is not in hierarchy order.
So, if you are important to use order, you must reorder the list.
Sample Code
private void Awake()
{
var monoComponentList = FindObjectsOfType<MonoComponent>().OrderBy(m=>m.transform.GetSiblingIndex()).ToList();
}
Other Resources
💖 💪 🙅 🚩
KENTO⚽️XR Engineer😎
Posted on October 29, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.