Search code examples
unity-game-enginegameobject

How can I find child gameobject?


I want to say somethings like..

Gameobject.find(child gameobject of specific parent Gameobject)

Can anyone help me. thanks!


Solution

  • GameObject.Find will search for a gameobject in the scene. To search a gameobject from a parent, use Transform.

    There are 2 ways of doing it:

    1. transform.Find("childname")
    2. transform.FindChild("childname")

    The 2nd option is deprecated but still functional, so you'd better use the 1st option.