O'Reilly logo

Unity iOS Essentials by Robert Wiebe

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

Task: load and save the players' preferences

The first thing that we need to do before loading player preferences is to think about the default values. For example, when the game is launched for the very first time, we could have the game volume off, set to the maximum, or set to something in between. If we decide that we want the game to start with the volume set to half of the maximum, we need a way to specify that for our game.

One way we can do it is to hardcode the default. This is a very common way for defaults to be specified, and simply requires us to check for the presence of the value. If it is not found, then set it to half and write it back out. The next time the game is run, the value will always be found.

One option would be to use ...

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