Search Unity

UI Saves

Discussion in '2D' started by Jichugn, Oct 27, 2021.

  1. Jichugn

    Jichugn

    Joined:
    Sep 14, 2021
    Posts:
    7
    I'm trying to create a game for a school project with the use of C#. Basically, it is an idle game but you earn through quizzes. I'm almost done but I have one problem. I have already created a save system for all the data I want to store through text files. However, I don't know how to save the UI "data'. By "UI Data", I mean when a button has become inaccessible already because the upgrade has been maxed, How do I save that? Basically, I want to save the state of the UI objects when I leave the game then load it again when opening.

    Example, the player already maxed an upgrade. Whenever I load the game again, the user would be able to buy that upgrade and it is easily exploitable. You can just max the upgrade, earn, close the game, and spam that cheap upgrade. What is the way around this? Thanks.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,735
    Your save should only save game data state, such as if something is maxed out, NOT what is presented in the UI.

    Proper UI just follows the game data at any given point in time.

    When you reload the game, the UI should be properly set up to reflect the state of that data.

    Any other halfway-data halfway-UI save scheme is going to prove VERY hard to maintain and debug.
     
    Jichugn likes this.
  3. Jichugn

    Jichugn

    Joined:
    Sep 14, 2021
    Posts:
    7
    I see. That makes sense. Thanks for the tip!
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    So you know for the future, this is the 2D forum where you should post 2D related issues and questions.

    More appropriate dedicated forums are available such as Scripting and UI.

    Thanks and good luck with your projects.
     
    Jichugn likes this.