In this video, Jesse Freeman teaches you how to use Unity’s PlayerPrefs class to store persistent data that can be read between game sessions. This is useful for storing settings and in this case, the high score from the player. Learning how to polish a Unity 5 game is an import skills for building a 2D game.
- [Voiceover] So now that we have the text field…to represent our score,…let's connect this up to our game.…In the Game Manager, let's open up the Game Manager code.…From here, we're gonna need a public property…that'll represent the instance of the score text.…Next, we're gonna need two private properties…that'll represent the timeElapsed and the bestTime.…Now, we wanna make sure that we reset the timeElapsed…every time we restart the game.…So here, in our ResetGame method,…let's set the timeElapsed to equal zero.…
Next, we're gonna want a way to format the timeElapsed…when we put it back into the text field.…To do this, let's create a new method…that'll return a string,…and we're gonna call this FormatTime,…and in this, we're gonna pass in a float…that'll be the value of time in milliseconds.…And to just get us started,…let's have it return the value…and we'll call ToString to convert it into a string.…Now the first thing we wanna do…is display the time and the bestTime…when the game is not running.…
So here inside of our update loop,…
Start watching to learn how to convert artwork into sprites, create repeating background textures with Unity's TexturePacker, and build reusable game objects such as players, obstacles, and enemies. Jesse also covers the basics of object pooling, working with custom UI components, and multiplatform publishing.
- Importing artwork
- Editing sprites
- Creating repeating background textures
- Building reusable obstacles
- Recycling game objects
- Building an object pool
- Creating the player
- Starting and ending the game
- Displaying and saving the score
- Adding menus and text
- Publishing a Unity game in different formats
Skill Level Beginner
1. Working with Sprites
2. Creating Repeating Textures
3. Creating Obstacles
4. Object Pooling
5. Creating the Player
6. Setting Up the Game
7. Polishing the Game
8. Creating More Obstacles
Publish to different formats5m 42s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.