root
object a
subobject a-1
subgroup a-2
subobject a-2-1
subobject a-2-2
subobject a-3
object b
subobject b-1
subobject b-2
object c
subobject c-1
subobject c-2
how to get the first level children with the parent being, for example, object a?
if i use Array(objecta.GetComponentsInChildre(Transform)) then i get not only first level
which is subobject a-1,subgroup a-2 and subobject a-3 but also children of the subgroup a-2
is there a way to get the first level children of given parent?
thanks, any help appreciated!
The transforms are returned in order of the top level downwards if you get all objects in the parent, so if you know the number of children that should be in the first level. i.e. 16, you can just cycle through objects 1-17 of the array… object 0 with be the parent.
so using that method, it’s possible to cound the first level childs using the first option, and then read from all transforms using that number + 1 to skip the parent.