Spawn new objects without replacing previous ones

Hello all,

I need to be able to instantiate objects from a List (not array). It’s an app where users can create lists of their own with different items inside those lists. In this case, I would like to be able to create objects (i.e. buttons) whenever a new list is added without having to replace the previous ones and renaming all of them. Here’s my code:

void SpawningThreshold (int buttonThreshold)
{
// Only add 1 new list at a time without touching the previously created list(s).
for (int i = 0; i < buttonThreshold; i++) {
if (transform.childCount < 5) {
newListButton = Instantiate (listButton) as GameObject;
newListButton.transform.SetParent(transform, false);
newListButton.GetComponentInChildren().text = appManager.SendListName();
} else {
displayListError.text = “Reached the maximum number of lists allowed.”;
}
}
}

What happens from this code is that objects are created one by one (not so sure though); however they are all created with the same name thus probably they are being recreated whenever the buttonThreshold variable reaches a higher valuable (e.g. 3 or w.e). As you can see, I’m only allowing a max of 5 lists created per player.
As I type in the name for the new list, the name is stored in the LIST< list class here> but only the latest list name entered is passed to the spawned buttons. The previously entered list names are ignored.
I’ve already created a “singleton” to manage the whole app (i.e. AppManager) and that’s where all the values are coming from.

In unity multiple different objects are allowed to have the same object name.