Guest User

Untitled

a guest
Apr 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4.  
  5. public class GameSettings : MonoBehaviour {
  6.     public const string PLAYER_SPAWN_POINT="Player Spawn Point";
  7.     void Awake(){
  8.         DontDestroyOnLoad(this);
  9.     }
  10.     public void SaveCharacterData(){
  11.     GameObject pc = GameObject.Find("pc");
  12.     PlayerCharacter pcClass=pc.GetComponent<PlayerCharacter>();
  13.     PlayerPrefs.DeleteAll();
  14.     PlayerPrefs.SetString("Player Name",pcClass.Name);
  15.     for(int cnt=0;cnt < Enum.GetValues(typeof(AttributeName)).Length;cnt++){
  16.         PlayerPrefs.SetInt(((AttributeName)cnt).ToString()+ "- Base Value",pcClass.GetPrimaryAttribute(cnt).BaseValue);
  17.         }
  18.     }
  19.     public void LoadCharacterData(){
  20.     GameObject pc = GameObject.Find("pc");
  21.     PlayerCharacter pcClass=pc.GetComponent<PlayerCharacter>();
  22.     pcClass.Name= PlayerPrefs.GetString("Player Name","Name Me");
  23.    
  24.     for(int cnt=0;cnt < Enum.GetValues(typeof(AttributeName)).Length;cnt++){
  25.     pcClass.GetPrimaryAttribute(cnt).BaseValue=PlayerPrefs.GetInt(((AttributeName)cnt).ToString()+ "- Base Value",0);
  26.     }
  27. }
  28. }
Add Comment
Please, Sign In to add comment