Advertisement
Burnner

SecurePlayerPrefs Example

Apr 20th, 2015
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using SecPlayerPrefs;
  4.  
  5. public class SecurePlayerPrefsDemo : MonoBehaviour {
  6.  
  7.     void Start () {
  8.    
  9.         //Write
  10.         SecurePlayerPrefs.SetFloat("float", 0.1f);
  11.         SecurePlayerPrefs.SetBool("bool", true);
  12.         SecurePlayerPrefs.SetInt("int", 100);
  13.         SecurePlayerPrefs.SetString("string", "amazing!");
  14.  
  15.         //Read
  16.         Debug.Log(SecurePlayerPrefs.GetFloat("float"));
  17.         Debug.Log(SecurePlayerPrefs.GetBool("bool"));
  18.         Debug.Log(SecurePlayerPrefs.GetInt("int"));
  19.         Debug.Log(SecurePlayerPrefs.GetString("string"));
  20.  
  21.         //Serialized Classes
  22.         //Write
  23.         SecureplayerPrefsDemoClass c = new SecureplayerPrefsDemoClass();
  24.         SecureDataManager<SecureplayerPrefsDemoClass> dataManager = new SecureDataManager<SecureplayerPrefsDemoClass>("name");
  25.         c.incremental = true;
  26.         c.playID = "tester";
  27.         c.type = 10;
  28.         dataManager.Save(c);
  29.  
  30.         //Read
  31.         SecureDataManager<SecureplayerPrefsDemoClass> dataManagerReader =
  32.     new SecureDataManager<SecureplayerPrefsDemoClass>("name");
  33.         c = dataManagerReader.Get();
  34.         Debug.Log(c.incremental);
  35.         Debug.Log(c.type);
  36.         Debug.Log(c.playID);  
  37.  
  38.     }
  39. }
  40.  
  41. using System;
  42.  
  43. [Serializable()]//Important
  44. public class SecureplayerPrefsDemoClass
  45. {
  46.     public string playID { get; set; }
  47.     public int type { get; set; }
  48.     public bool incremental { get; set; }
  49.  
  50.     public SecureplayerPrefsDemoClass()
  51.     {
  52.         this.playID = "";
  53.         this.type = 0;
  54.         this.incremental = false;
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement