How do I Save instantiated Bundle to scene ?

how do I save my instantiated objects to my scene .
for example i have instantiated “bubblemoon” in my scene
how do i go about saving that object to the scene so that it remains in the scene at next run-time.

If you’re talking about doing it magically, it doesn’t work that way. What you’d have to do is implement saving functionality. That means that any dynamic elements of the scene that aren’t emergent or can not be inferred by other object’s states needs to be saved to disk for reloading when the player reenters a given scene. It’s quite a task. You must ask yourself several questions before proceeding.

  1. Will there be multiple players, or save-games? Typically, this is true, like in Oblivion or Resident Evil.
  2. Is the player allowed to travel from scene to scene freely, or is it a linear experience? If linear, the task is greatly simplified, because you can discard stale information (like previous scenes) and only save the current one and player inventory and the like. Otherwise if you can travel all over, like in Fallout, you need to save some of the state of the entire world.
  3. Is it multiplayer? If so, each copy of the save game needs to maintain everything for every player for the reasons of preventing cheating, unless you use some checksums to detect altered save game files.
  4. Is the world procedurally generated, like Minecraft? If so, you’ll have to save the entire damn world.

Good times, for sure, but very doable if broken down into small chunks of work.

Funny, someone else just posted that their objects were staying in the editor after they stopped playing. Anyway, you might find something in the Asset Store to do this for you. Otherwise, you can add a script that copies the properties (transform, etc) of the object each frame and monitor the Application.isPlaying property. When it changes state, create a new object with the same name and copy the properties into it.

You need this script to execute in Edit mode (after you exit Play), so add the ExecuteInEditMode attribute:

You would attach this script to the prefabs right after you instantiate them for optimal results (i.e. don’t want to run it on all of the objects in the scene).