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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

About Saving and Loading Data

Discussion in 'Scripting' started by bekiryanik, Jun 28, 2018.

  1. bekiryanik

    bekiryanik

    Joined:
    Jul 6, 2014
    Posts:
    191
    Hello,

    Currently i am working on a car game project which the player will be able to do customizations on car parts such as wheel, painting and some other things. I actually searched for saving and loading data before this game i was using playerprefs in my games but in this game, it seems that it will be longer way for this project. The thing what i wanted to do, is to save everything what happens in the screen. For example, when the player changes the wheels of the car, this is going to be saved or when the player changes the color of car, this is going to be saved. When the game is loading, it will load the data and let the player have what he did before he/she closes the game. Is it possible to save all of the things what is done by the player in the game?

    Regards
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Yes, it's possible. If all you want is a player history that you can display, you could simply save it to a text file with each line being a different action.

    If you want the player to reverse their actions through that history, that will become a bit more complicated.
     
    bekiryanik likes this.
  3. bekiryanik

    bekiryanik

    Joined:
    Jul 6, 2014
    Posts:
    191
    Hi Brathnann,

    Thanks for your answer. I want to save all of the things what player do about its car on the screen and then when he reopens the game, i want player to start playing by having a car which he saved before he closes the game. So, how is that possible?
     
  4. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    681
    Maybe you would find this helpful: http://wiki.unity3d.com/index.php/ArrayPrefs2 - with this you can save more complex data structures to player prefs, like arrays of colors or strings, in which you can store the properties for your car. An oldie but goodie, thanks to @Eric5h5
     
    bekiryanik likes this.
  5. bekiryanik

    bekiryanik

    Joined:
    Jul 6, 2014
    Posts:
    191
    Thanks a lot, i take a look at it right away.