Been fighting with some code all day, so I created a test example, and Foreach definately appears to be skipping items! I’m new to Unity and C# so could be something I’m doing, but I can’t tell what!
I have 2 Game objects (Container1 and container2)
I placed 5 Game objects into container1 (GameObject1,Gameobject2,…)
I added the following script to container 1:
void Start()
{
GameObject newParent = GameObject.Find("Container2");
foreach (Transform child in transform)
{
child.parent = newParent.transform;
}
}
And after running this Object1,object3, and object5 are moved to Container2
Object2 and Object4 remain in container1