Search Unity

Saving a score through many scenes that always return to a main menu

Discussion in '2D' started by drivelcon843, Sep 21, 2018.

  1. drivelcon843

    drivelcon843

    Joined:
    Sep 14, 2018
    Posts:
    3
    Okay, I have a main menu, and in it there's a play button that when pressed goes to one of four randomly selected mini-game scenes. And after the player gets five tries (scoring up to five points), the game returns to the main menu for the player to press the play button again, but now they will start with however many points they just finished with. This process will repeat, always with points accumulating.

    Is it simply making sure the same 'DontDestroyonLoad' game object (which would just be keeping track of the score) is in the main menu and all four scenes?

    (I've foolishly designed the four games separately, then the main menu, and am now trying to tie it all together)


    Thanks for the help.
     
  2. OfficeThrashing

    OfficeThrashing

    Joined:
    May 18, 2018
    Posts:
    13
    try PlayerPrefs.GetInt("NoOFTurns") and then increment it till 5

    when it is 5 return to the main menu and reset playerprefs to 0.