Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

How can I export a runtime scene and import it into a game?

Discussion in 'Editor & General Support' started by Rob_Elias, Apr 8, 2021.

  1. Rob_Elias

    Rob_Elias

    Joined:
    Mar 21, 2014
    Posts:
    14
    Hi! I'm making a runtime editor and I want to export the scene (game) made in it and import it into a game. Can you give me any indication of where to start studying?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    5,675
    You're going to have to figure out a way to serialize all the data that comprises the scene:

    - References to prefabs (as string prefab names, or using Addressables)
    - positions/rotations/scales of those prefabs
    - Any state of those objects that is not part of the prefab itself (maybe a spawned-in light switch is turned on rather than its default of being off)
    - Any other game logic related to your game specifically and any relationships between those objects.

    Gather all that data, serialize it to a file, and then write the opposite logic that can deserialize all of it and re-instantiate all the objects in the appropriate places and states.

    It's not trivial and it depends heavily on how your game in particular is set up.
     
    Joe-Censored likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,084
    This topic is basically the same as creating a save game system. There's lots of threads on the topic.
     
    PraetorBlue likes this.
unityunity