Changing sorting layer of Transform and all of its children

I have a GameObject (let us call it progenitor) that has simply a Transform but it has many children. Some of the children have other children. Can I change the sorting layer in the progenitor and affect all of the children?
Incidentally, the progenitor is part of a Prefab.

SortingLayer is evaluated per-renderer, so you’ll need to go thru the child transforms of each Transform in the hierarchy and GetComponent to set it manually. edit: GetComponentsInChildren()

If the intention is to keep all of the Renderers sorted together, you could use the Sorting Group component on the top level GameObject.

2 Likes

So for anyone looking for the answer, indeed Sorting Group seems to do the job of changing sorting layers for all children of an object!

1 Like