Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Unity Game Development Blueprints
  • Toc
  • feedback
Unity Game Development Blueprints

Unity Game Development Blueprints

By : John P. Doran
4 (6)
close
Unity Game Development Blueprints

Unity Game Development Blueprints

4 (6)
By: John P. Doran

Overview of this book

If you want to build enticing projects with Unity, this book is for you. Readers who are familiar with the basics of how to create simple projects in Unity will have an easier time.
Table of Contents (11 chapters)
close
10
Index

Saving a high score


To begin with, let's look at one of the simplest ways to save/load data for individual pieces of simple data using the PlayerPrefs class.

The PlayerPrefs class

The PlayerPrefs class allows us to store small amounts of data on the end user's machine. Using PlayerPrefs is a great way to save data for user levels, the coordinates of where enemies are, or a high score so that when the user comes back to the game, it shows the highest score achieved over the course of all games played.

When I say small amounts of data, on the WebPlayer you can store only 1 MB of data, but this is the only limitation aside from hard drive space as of this writing.

The PlayerPrefs class can store the following types: float, int, and string. There are two key functions for each of the types Get and Set with the type added afterward (GetFloat, SetString, and so on).

The Set functions

The Set functions take in two parameters: the first being a string and the second of the type you're trying to set. This...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete