Important Notice:

As of September 15, 2016, we no longer publish new courses on this website. We encourage you to use your Digital-Tutors credentials to sign in on Pluralsight where you'll find all new creative courses, skill tests and paths, 1:1 mentoring and more.
Unity Mobile Game Development: Saving Data and Highscores
See Details
Released Jan 2, 2012
Chris Glick

Pluralsight

Chris Glick
In this Unity tutorial, we’ll learn how to save data between play sessions with PlayerPrefs and create a highscore level for deployment to iOS or Android. Through these lessons we’ll learn how we can use the GUI class to draw various text and images on our screen. From there, we will examine time-saving techniques for placing our GUI elements with the inspector accurately. We'll learn how we can use arrays to store multiple pieces of data and how we can display lists using for loops. Then we'll refactor our array into a highscore class. With our display set up, we will learn the commands to access our player prefs and the logic we need to sort and store our data. Finally we'll see how we can use mobile keyboards and examine a faster method of saving data for mobile platforms. From basic preferences like display settings to more complex structures like high scores, it's important to understand how to save data after we close our game.
Introduction and project overview
1

Introduction and project overview

 
01:10
Examining our start scene and the scripts that are included
2

Examining our start scene and the scripts that are included

 
03:36
Consulting our game design document to begin our script
3

Consulting our game design document to begin our script

 
06:10
Using a GUI.Box function to draw our first highscore
4

Using a GUI.Box function to draw our first highscore

 
05:48
Using a Vector2 to offset our text placement for control
5

Using a Vector2 to offset our text placement for control

 
05:14
Automatically centering our text using our Location class
6

Automatically centering our text using our Location class

 
10:27
Creating a new GUI Style to format our text
7

Creating a new GUI Style to format our text

 
06:10
Using a built-in array to store multiple pieces of data
8

Using a built-in array to store multiple pieces of data

 
07:34
Displaying our entire array using a For loop
9

Displaying our entire array using a For loop

 
07:06
Adding a height offset to display all our names
10

Adding a height offset to display all our names

 
07:57
Refactoring our arrays into a class for easier organization
11

Refactoring our arrays into a class for easier organization

 
08:55
Displaying our highscore array correctly over our graphics
12

Displaying our highscore array correctly over our graphics

 
07:41
Saving game data using PlayerPrefs to store information
13

Saving game data using PlayerPrefs to store information

 
07:35
Creating a testing interface to set PlayerPrefs data
14

Creating a testing interface to set PlayerPrefs data

 
07:02
Synchronizing our PlayerPrefs with our local highscore class
15

Synchronizing our PlayerPrefs with our local highscore class

 
11:54
Synchronizing our Rounds and Kills data
16

Synchronizing our Rounds and Kills data

 
05:35
Scripting an add new highscore function
17

Scripting an add new highscore function

 
10:20
Testing if we need to create a new highscore
18

Testing if we need to create a new highscore

 
04:29
Moving our highscores down using a reverse For loop
19

Moving our highscores down using a reverse For loop

 
11:18
Inserting our highscores into our data correctly
20

Inserting our highscores into our data correctly

 
05:37
Letting the player enter their name using a GUI.TextField
21

Letting the player enter their name using a GUI.TextField

 
09:01
Using GUI.color to change our highscore text colors
22

Using GUI.color to change our highscore text colors

 
06:01
Creating flashing text using Mathf.PingPong and GUI.color
23

Creating flashing text using Mathf.PingPong and GUI.color

 
06:08
Testing our Highscore Display script to find bugs
24

Testing our Highscore Display script to find bugs

 
10:46
Tracking game ID's to make sure we don't duplicate data
25

Tracking game ID's to make sure we don't duplicate data

 
11:14
Changing the location of our game ID check to remove bugs
26

Changing the location of our game ID check to remove bugs

 
08:15
Using the iPhoneKeyboard class to get user input on Android
27

Using the iPhoneKeyboard class to get user input on Android

 
06:20
Saving the PlayerPrefs data to disk in case our game crashes
28

Saving the PlayerPrefs data to disk in case our game crashes

 
04:28
Using the PreviewLabs PlayerPrefs plugin for speed on mobile
29

Using the PreviewLabs PlayerPrefs plugin for speed on mobile

 
06:59
Examining the final game code in reference to the highscore system
30

Examining the final game code in reference to the highscore system

 
03:44