I am trying to make a racing game. I have 10 cars and every car have attributes like speed, brake force, acceleration and handling. Player can upgrade cars with buttons. I have to save car upgrades and set the texts of buttons (like, Speed Level 1). I tried PlayerPrefs but I have so much data to save. My question is, which way I have to use for saving that data?
Asked
Active
Viewed 1,405 times
-1
-
2Your question has been answered [here](https://stackoverflow.com/questions/34426570/best-way-to-save-data-in-unity-game) – TEEBQNE Oct 17 '21 at 16:55
2 Answers
1
Create a class
public class CarAttributes{
private float speed;
private int levelNumber;
}
Create a variable which will store all data of the car
CarAttributes car1 = new CarAttributes();
car1.speed = 100.0f;
car1.levelNumber = 3;
....
PlayerPrefs.SetString( "playerCar1", JsonConvert.SerializeObject(car1) );
To load data use
CarAttributes car1 = JsonConvert.DeserializeObject<CarAttributes>( PlayerPrefs.GetString( "playerCar1" ) );

Kaushik Chandru
- 15,510
- 2
- 12
- 30
0
There is no one single question for this, saving data in unity is just like saving data in every running program. I'll try to enumerate some of the methods :
PlayerPrefs : As @KaushikChandru already answered you can use player prefs to save the data, just serialize them and save them as a String, and then you can deserialize them to get them back as objects.
File : Instead of using a PlayerPrefs you can use a File instead, here is a useful video that explains that (here )
Use a database (sql lite) : The second one would be to use a database (local or remote). I suggest using SQL Lite, here is a useful tutorial for that (here)

Abdelkrim
- 1,083
- 8
- 18