Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Prevent Scenes from "Resetting"

Discussion in 'Editor & General Support' started by LevRaskolnikov, May 18, 2023.

  1. LevRaskolnikov

    LevRaskolnikov

    Joined:
    Dec 7, 2022
    Posts:
    13
    Hi, so my game is sort of set in a little town, and every building you enter is a different scene. I successfully managed to make each building an Additive scene that loads when the player enters them using SceneManager.LoadScene(X, LoadSceneMode.Additive), and successfully manage to unload the scenes using SceneManager.UnloadSceneAsync. However, when the player re-enters a building they just left, the scene "resets" (as in, all enemies and scripted events respawn and reset). Is there a way to somehow save the information in the additive scene so that when the player "re-enters" the scene, everything they did in said scene remains the same?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,604
    Yes, it's called implementing a data-persistence system, or generally known as a save system. You will want to record all relevant data, store it somewhere, and pull from it when entering the scene.

    If you haven't done a save system yet, there's lots of tutorials out there to get you started.
     
    PraetorBlue likes this.
  3. LevRaskolnikov

    LevRaskolnikov

    Joined:
    Dec 7, 2022
    Posts:
    13

    This is very good to know. Do you recommend any tutorials in particular?
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,604
    I would follow any decent tutorial, mostly to get to grips with what it takes to write and read data out to a file, which is the first thing you need to learn. Play around with the concepts in a standalone project until you get to grips with the concepts involved.

    Other than that it's just learning as you go. Figure out the data you need to save, and research ways to structure things so that you can achieve this. I wouldn't be able to point to a specific tutorial, as this is the the kind of thing that varies greatly on a per project basis. But it should be front and center in your mind as many other systems need to be build with saving in mind, not as an after thought.