- Home /
Which is the correct way to save character preferences like clothes?
Imagine a scene where I select how my character is (nose, eyes, clothes...).
Now I change to the next scene and I want to see my character with my previous selections. How is the correct way to achieve this? PlayerPreferences? JSON file?
I have to load these data before every scene?
Answer by etaxi341 · Mar 10, 2020 at 08:22 AM
Do you mean saving or just keeping it until the game is closed? If you don't want it to reappear after restarting the game then just make some static class that holds this data. Otherwise for small savefiles I would do JSON or BinaryFormatted, for Bigger ones maybe SQLite
By now, I only need to keep data until game is closed. I'm a bit noob. Could you show me some tiny example of how to do this with a static class? Could I store a complete GameObject or should I store every piece of customization and load again and again?
Okay so here is how I would do it.
Create a static class that contains variables like "nose", "eyes", ...
In your character selection set the values in this static class
When loading the next scene, read the values from this static class
This works because static classes only exist once. See here how static classes work.
Your answer
Follow this Question
Related Questions
Is there any way to restore previous save of C# script 0 Answers
Sharing violation on path... Save Game Issue. 1 Answer
Switching character and keeping animations in Unity default third person controller 1 Answer
store data locally to handle items/enemies appear only once 1 Answer
Cinemachine character animation help 1 Answer