title: UnityException: Transform child out of bounds
body: <p>I have six panels were the current effects are showing. If the amount of effects is 0, I want all of them to disappear. The <code>effectOff()</code> deactives all panels and effect images. The six panels have each six children effect images. (blue, green, red etc.). The code should make all of them deactivated.</p>
  
  <pre><code>public GameObject effectbar;
  
  public void effectOff()
  {
      for (int i = 0; i &lt; 6; i++)
      {
          for (int a = i; i &lt; 6; i++)
          {
              effectbar.gameObject.transform.GetChild(i).GetChild(a).gameObject.SetActive(false);
          }
          effectbar.gameObject.transform.GetChild(i).gameObject.SetActive(false);
      }
      effectbar.SetActive(false);
  }
  </code></pre>
  
  <p>The <code>effectbar.gameObject.transform.GetChild(i).gameObject.SetActive(false);</code> line gives a <code>Transform child out of bounds</code> exception. How do I fix that? I read that it throws an error because the system doesn't know if a children object really exists. Thanks forwards.</p>