How can I find child gameobject?

user3952722 picture user3952722 · Sep 10, 2014 · Viewed 70.7k times · Source

I want to say somethings like..

Gameobject.find(child gameobject of specific parent Gameobject)

Can anyone help me. thanks!

Answer

Jay Kazama picture Jay Kazama · Sep 10, 2014

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.