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

GameObject Search By Unity Tag

What is Unity Sprite ?

What is Unity FBX?

Unity Main Camera Tracking Player

Using Unity Editor Black Theme