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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Problem with new game

Discussion in 'Scripting' started by JPCannon, Mar 23, 2015.

  1. JPCannon

    JPCannon

    Joined:
    Sep 25, 2013
    Posts:
    37
    Hi. In my game i have problem with new game option. I`m using PlayerPrefs.DeleteAll(); and after that i set new values for some static variables. But it`s dosen`t work if i don`t get off editor, and play it again. I must add something to have reload after new game? Now i`m loading new scene after use new game but it`s dosen`t work if i don`t reset editor.
     
  2. nostalgicbear

    nostalgicbear

    Joined:
    Mar 21, 2013
    Posts:
    98
    This is really unclear
     
  3. JPCannon

    JPCannon

    Joined:
    Sep 25, 2013
    Posts:
    37
    Ok simple version of problem. Push button Play in Editor->Click new game (which have function PlayerPrefs.DeleteAll() and some set variables in it and function to change scene on function end) -> nothing happends, only scene is changed, but all data are the same.
    Click button "Play" in editor again to stop game -> Click button "Play" again to star game again -> all data are cleared and game work with reset data.

    I want to have reset data without pressing "Play" again :)
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,386
    Just do PlayerPrefs.DeleteAll() again.
     
  5. JPCannon

    JPCannon

    Joined:
    Sep 25, 2013
    Posts:
    37
    But why this isn`t working on the first time? :p If this works i should can use my new game function after new scene loaded :p Effect should be the same.