Answers for "c# set object child layer"

C#
1

c# set object child layer

// Check if game object has child:
if (transform.childCount >= 0)
{
  	// Set child layer:
	foreach (Transform child in gameObject.GetComponentsInChildren<Transform>(true))
	{
		child.gameObject.layer = LayerMask.NameToLayer("Default");
	}
}
Posted by: Guest on July-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language