How to properly save with newly created objects

The question is still difficult for me personally, I ask for help.

  1. There is a character who creates objects in the scene by means of Instantiate.
  2. The application will be for mobile devices, as far as I understand there is a difference in the methods of saving, I still do not really understand what exactly, but as if in socialization. Although for a start I have to somehow save the progress of the game.
  3. I read the documentation, but it’s hard for me to deduce the result without seeing a single example.
  4. I think it should be something like this:
    -Create a dynamic array
    -Collect the location of objects that are created from the moment of something, or record immediately when they are created, or record all objects that are in the scene during OnSceneExit, and here, too, I have not figured out exactly how to separate the data of new objects from those that have already been saved.
    -Somehow pass this to an array.
    -Convert the array to some kind of preservation.
    -When loading the game at the start, enter the instantiate function, which, based on the coordinates from the array, will create objects at the same coordinates.
    Who will tell me what how to implement this and what to do with it at all, perhaps there are already ways to do it or other options. I haven’t found a single workable solution yet. Image from the test location, so that it would be more understandable. The object is just a cube for now.

https://ibb.co/xYQfX8c

Pretty close. Try using the FlieManagement asset to save and load your arrays of types.

You’ll probably get better help in the Scripting section.

That said, the Pixel Crushers save system (included in assets such as the Dialogue System for Unity) handles spawned objects like this:

A Spawned Object Manager in the scene has a list of prefabs.

Each of the prefabs has a Spawned Object component. When spawned (instantiated) or destroyed/returned to pool, it tells the Spawned Object Manager.

The Spawned Object Manager maintains a list of spawned objects. When saving the game or leaving a scene, it saves which prefabs have been spawned and their current positions. When loading a game or returning to a scene, it spawns those prefabs back into those positions.

This works well for varied prefabs, such as enemies, loot, etc.

However, your screenshot looks like you may be managing a map of voxels. If so, you’ll want to write something more custom to handle your voxel map.