I’m trying to go through a scene and take all objects with a specific tag, and then take all of the children within those objects and then add all of that to a dictionary. The problem is that at some point it adds another Key.
SomeDictionary.Clear();
GameObject[] fieldCollection = GameObject.FindGameObjectsWithTag("FieldImage");
foreach (GameObject field in fieldCollection)
{
foreach (Transform child in field.transform)
{
if (child.tag == "Toggle")
{
SomeDictionary.Add(field.name, child.name);
}
}
}
My thoughts are that the problem is related to the Foreach loops. Any help is appreciated