GameObjectExtension.SetLayerRecursively C# (CSharp) Method

SetLayerRecursively() public static method

public static SetLayerRecursively ( GameObject gameObject, int layer ) : void
gameObject GameObject
layer int
return void
    public static void SetLayerRecursively(this GameObject gameObject, int layer)
    {
        gameObject.layer = layer;
        foreach (Transform child in gameObject.transform)
        {
            child.gameObject.SetLayerRecursively(layer);
        }
    }
}
GameObjectExtension