InvalidOperationException Collection was modified;

Getting this error here:

tList.Add(PlatformOBJChild);
foreach (Transform t in tList) // <-- Error here
{
if (t == null)
{					     tList.Add(PlatformOBJChild);
}
}

You shouldn’t modify the contents of collections while you’re iterating on them.

You can use a temporary list to do this:

List<Transform> itemsToAdd = new List<Transform>();

foreach (Transform t in tList) {
    if (t != null) {
        foreach (Transform child in t) {
            itemsToAdd.Add(child);
        }
    }
}

foreach (Transform item in itemsToAdd) {
    tList.Add(item);
}

Note that the first foreach loop will only add children one level deep. You could use a recursive function (or something similar) to recursively add all children and their children.

You are receiving that error because you are modifying your collection while iterating over it… that error is thrown on the second iteration because you have added another element. Read this if you want a more in depth explanation. Bottom line: do not add to, remove from or change values of any collection while you are looping through it.

If you wanna to delete an element (or more) just iterate with for/while and increment index only when the item is not deleted and pay attention to if you save count (n = exampleList.Count) in a variable to decrement when an element is deleted .

    for(int i = 0; i<exampleList.Count;)
    {
        if(exampleList *== null)*

{
exampleList.Remove(exampleList.);
continue;
}
++i;
}