Home > other >  How I can save and load level in unity3D, C# , Mobile Game?
How I can save and load level in unity3D, C# , Mobile Game?

Time:11-24

How I can save a level in player's data when player complete level and go to next level or when player quite the game. Thank you!

CodePudding user response:

There are many, many different ways to accomplish this. Since your question is so broad, I can only offer broad answers for you to start your research, in rough order of complexity.

PlayerPrefs: If you have a very limited amount of save data, perhaps 5-10 data points, this is a convenient library provided by Unity to set and get strings, ints, and bools. It operates differently on each platform, but "just works" for the most part.

Writing to Files: If you have more data than should be saved using PlayerPrefs, or you'd like your files to be editable/readable/transferrable by your players (or you, during development, since PlayerPrefs writes to the underlying store in binary format, typically), you can do this. Google up "reading and writing files C#" for tutorials and APIs on how to do this. You can also obfuscate these files by encrypting/decrypting them, but you'll need to be aware that converting them to a binary format has security implications, so don't go down this route (encrypting) until you know what you're doing.

Writing to [remote] databases: If you have a great deal of data (images, audio, gigs of text), then a database might be an option for you. That's very much beyond the scope of this question, however, but you should know that it's relatively easy to do this with C#.

There are other esoteric solutions, obviously, but that should get you started.

  • Related