title: Getting the children of a transform skips every other child
body: <p>I wish to get the children of the children of my <code>gameObject</code>. I'm not talking about recursion, I just have a <code>Whole</code>, under which have many <code>Segment</code>s, and every segment has a couple of <code>Tile</code>s in them like so:</p>
  
  <p><a href="https://i.stack.imgur.com/pFfOV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pFfOV.jpg" alt="enter image description here"></a></p>
  
  <p>The goal is to get those tiles into one collection and then parent them under the given gameobject. </p>
  
  <p>To do so, I do this:</p>
  
  <pre><code>foreach (Transform child in whole.transform)
  { 
      foreach (Transform tile in child)
      {
          //even with the following line commented out it's the same. 
          tiles.AddElement(tile.GetComponent&lt;Tile&gt;());
          tile.SetParent(transform);
      }
  }
  </code></pre>
  
  <p>which is pretty straightforward, except it doesn't work. It throws no exceptions, and fetches every other child like so:</p>
  
  <p><a href="https://i.stack.imgur.com/Hkgle.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hkgle.jpg" alt="enter image description here"></a></p>
  
  <p>The code is very basic and definitely should work. Those <code>tile</code> prefabs are identical, no difference between them except for their location maybe. </p>
  
  <p>Edit: and all the objects I operate on are active. Even after this setup, I find the skipped tiles right where they were left, all of them are active. In debug mode I see the <code>ChildCount</code> is 5. I step through the loops, and it just skips every other child. </p>
  
  <p>EDIT AGAIN:</p>
  
  <p>I have a hunch it's a Unity bug. </p>
  
  <p><a href="https://i.stack.imgur.com/RUmsv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RUmsv.jpg" alt="enter image description here"></a></p>
  
  <p>Now my <code>i</code> is <strong>1</strong>, which is the second index as we all know it. And it returns the third tile, <code>tile (2)</code> (they are tile, tile (1) and tile (2) in this order).</p>
  
  <p>Guess who files a bug report. </p>