title: Best practice for getting all child game objects?
body: <p><strong>Hello :-)</strong>
  I'm new developer in <strong>Unity3D.</strong> 
  I have a question what is the best practice of getting all children GameObject.</p>
  
  <p><a href="https://i.stack.imgur.com/WrGy5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WrGy5.png" alt="GameObject&#39;s hierarchy "></a></p>
  
  <p>I wanna active or de-active 3 buttons (Camera, SNS, Save Buttons) under some conditions.</p>
  
  <p>here is my code to do that. but I think this is not good.
  I would like to replace it. There are so many foreach statements.
  When the parent game object will be added, foreach loop will be added also.</p>
  
  <hr>
  
  <pre><code>var uiRoot = GameObject.Find("UIRoot");
      if (uiRoot != null)
      {
  
          foreach (Transform camera in uiRoot.transform)
          {
              camera.gameObject.SetActive(true);
  
              foreach (Transform anchor in camera.transform)
              {
                  anchor.gameObject.SetActive(true);
  
                  foreach (Transform buttons in anchor.transform)
                  {
                      if (buttons.gameObject.tag == "PictureTag")
                      {
                          buttons.gameObject.SetActive(!isCameraVisible);
                      }
                      else if (buttons.gameObject.tag == "CameraTag")
                      {
                          buttons.gameObject.SetActive(isCameraVisible);
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <hr>
  
  <p>Do you guys have a good idea for that? 
  Help me, Thanks.</p>