O'Reilly logo

Unity 4 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving and loading the local high score

In this section, we will be creating the LocalHiscore script, which we will use to save and load the users' data. We will use PlayerPrefs, BinaryFormatter, and MemoryStream to save and load the user data. Then, we will add the ability to save and load the local high score to our UIHiscore script.

Engage thrusters

Now we can start creating the LocalHiscore script using the following steps:

  1. Navigate to Chapter8 | Scripts | C#/Hiscore (for C# users) or Chapter8 | Scripts | Javascript | Hiscore (for Unity JavaScript users), right-click and navigate to Create | C# Script (for C# users) or Create | Javascript, and name it LocalHiscore.
  2. First, we will create a random name for the default user and the SaveUserData() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required