BoolPrefs

From Unify Community Wiki
Revision as of 19:26, 19 October 2009 by NCarter (Talk | contribs)

Jump to: navigation, search

Author: Eric Haines (Eric5h5)

Description

So you're missing SetBool and GetBool from PlayerPrefs? Worry not, here they are!

Usage

Have this script somewhere in your project. Call it PlayerPrefsX, and then you can use PlayerPrefsX.GetBool and PlayerPrefsX.SetBool as you would expect. These use PlayerPrefs.SetInt and GetInt behind the scenes (0 = false, 1 = true), so they're just convenience functions.

PlayerPrefsX.js

<javascript>static function SetBool (name : String, value : boolean) { PlayerPrefs.SetInt(name, value?1:0); }

static function GetBool (name : String) : boolean { return PlayerPrefs.GetInt(name)==1?true:false; }</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox