![]() So, what’s happening? Well, as promised, PlayerPrefs saves the player’s game. The actual act of saving your game takes only a few lines of code. Next, some variables to hold the values to save will be needed. To begin, the Start and Update methods can be commented out or deleted as they will not be used to demonstrate the save functionality. Double-click the script to open Visual Studio. To see what saving a game entails, start with the SavePrefs script. Call these scripts SavePrefs and SaveSerial. You create scripts by right-clicking in the Assets window and selecting Create->C# Script as shown in Figure 2. Once you create the project, you’ll need two scripts. For this project, you will want to use the 2D template for the easiest setup as shown in Figure 1. You just need a project and a couple of scripts. There’s minimal setup involved in testing these out. Both methods have their pros and cons, which will be covered as the practices are explored. On the other hand, the not so easy way involves serializing data and writing to a file for later use. Give a value to a key, call Save, and you’re done. They can be quickly described as “the easy way” and “the not so easy way.” The easy way involves Unity’s built-in PlayerPrefs system. Unity provides two ways to save a game’s data. Only when a game is short enough that it can be completed in a single session does the need for saving data diminish, but even in those scenarios, the feature can be very handy. Many games require multiple play sessions to see to the end, and it’s now expected that developers include ways to save the game and come back later. The need for saving all kinds of data, ranging from how much progress the player made in-game or their character’s statistics, became universal whether the game be a simple, linear adventure from beginning to end or it consists of a huge open world. But it didn’t take long for technology to improve, and thus games got longer and more complex. ![]() ![]() At best, a game would save a high score and leave it at that. Saving Game Data with Unity - Simple Talk Skip to contentīack in the day, many games had little need for saving data since you could finish a game in about an hour.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |