I have a GameObject which contains children and grandchildren. I would like to change the layers of the entire Parent folder with another layer. Currently the parent and her children I was able to change layers, I add grand to child and it didn't work, it was the same results as I typed child. I have 6 children who have children themselves.
newBuilding.gameObject.layer = 0;
foreach (Transform child in newBuilding.transform) child.gameObject.layer = 0;
foreach (Transform grandChild in newBuilding.transform) grandChild.gameObject.layer = 0;
↧