Checking If Unity GameObject Has Child Object

In Unity we use the childCount property to check if a GameObject has a child object or objects.

If this value is greater than 0 it has at least 1 child object.

An example of its use is given below..

GameObject go = GameObject.Find("TestGameObject"); if (go.transform.childCount > 0) { //Child object exists } else { //Child object NOT exists }

In our example, we found whether our GameObject variable named "go" has "childCount" property and its "child" object or objects.



You May Interest

What is Unity FBX?

What is Unity IL2CPP ?

Using Unity Editor Black Theme

What is Unity SiblingIndex ?

What is Unity Asset Store?