- Home /
Question by
Qdevesh · Oct 12, 2021 at 05:03 PM ·
c#gameobjectarray of gameobjectssortingsorting order
How to sort a array of gameobjects same as hirearcy react
Is there any meathod in unity through which i can sort a gameobjects array as likely given in the hirearcy no matter a object destroy or instantiate i want it work like hirearcy respond I have a some like of code already written sorting by its sibling index but it does not work it does not react as like as hirearcy react to a new instantiated object VERY THANKFULL TO YOU THAT YOU EVEN SEE THIS REMEMBER THAT GOD HELP THOSE WHO HELP OTHERS
//code starts for now
GameObject[] obj = GameObject.FindGameObjectsWithTag("Pieces").OrderBy(go => go.transform.GetSiblingIndex()).ToArray();
Comment
Your answer
Follow this Question
Related Questions
Sort list game objects based on name 3 Answers
Calculate position in an array of gameObjects 0 Answers
Multiple Cars not working 1 Answer
Trail Render is rendering behind the background sprite 1 Answer
Distribute terrain in zones 3 Answers