Advertisement
Munchy2007

GenericSerialiser4

Apr 25th, 2016
1,715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. [System.Serializable]
  6. public class PlayerInfo  {
  7.  
  8.     public string playerName = "Default Name";
  9.     public int health = 100;
  10.     public List<InventoryItem> inventory = new List<InventoryItem>();
  11.  
  12.     public static PlayerInfo Load()
  13.     {
  14.         var playerInfo = Doofah.GenericSerialiser.LoadFromPlayerPrefs<PlayerInfo>("PlayerInfo");
  15.         return playerInfo != null ? playerInfo : new PlayerInfo();
  16.     }
  17.  
  18.     public void Save()
  19.     {
  20.         Doofah.GenericSerialiser.SaveToPlayerPrefs("PlayerInfo", this);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement