Child Sorting Layer Order in Layer

Dear Forum,

Is there an easy way to set the order layer of child gameObjects to the same as their parent gameObject, or - even better - to only use the parent order in layer and disregard the children?

Thanks!
Jon

Hey Jon,

Here’s a possible snippet you could put in your Start()

        foreach (var v in this.GetComponentsInChildren<T>())
        {
            v.renderer.sortingLayerName = this.renderer.sortingLayerName;
        }