How to save many objects information in scene?

For example, a world map likes Total war, there are many cities that have independent population, building level etc.

What i am doing now is, make a Transform list, and then drag the objects to the list one by one in inspector. Then, i just need to use for loop to save/load on the list to xml file.

However, if there are hundreds cities, like Europa 4, drag them one by one in inspector seem to be a very bad idea.

So, i wonder any better method?

This is a very well-trodden subject area. Google around youtube for various tutorials on load/save game systems. There are many excellent examples of simple save systems as well as much-more involved ones. The broad answer is “the more you save, the more work you have to do,” so choose wisely when designing your save system.

If each object has a particular component on it, you can use FindObjectsOfType() and populate the list in one fell swoop. (Be advised, this function is not very performant, so make sure you only call it once and cache the result.)

Or append them to a parent at spawn and iterate over all the children