- Home /
Question by
$$anonymous$$ · Dec 02, 2019 at 07:55 AM ·
scripting problemerrorunity 2deditor-scriptingchild object
Alphanumeric Sorting and GetChild not working!!
I have enabled alphanumeric sorting which is really efficient for my current project. The problem is whenever i try accessing the child gameobjects with getchild function its return the objects as it would be in transform sorting not as is in the alpha numeric sorting in editor. How the Gameobjects are in editor (with alpha numeric sorting)
looping through the child gameobjects in the script.
screen-shot-2019-12-02-at-13314-pm.png
(15.4 kB)
screen-shot-2019-12-02-at-13419-pm.png
(46.1 kB)
Comment
Answer by lgarczyn · Dec 02, 2019 at 09:50 PM
Just add
using System.Linq;
At the start of your file and to get the sorted children use
Transform[] sortedChildren = (transform as IEnumerable<Transform>).OrderBy(child => child.name).ToArray();