Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System;
- public class GameSettings : MonoBehaviour {
- public const string PLAYER_SPAWN_POINT="Player Spawn Point";
- void Awake(){
- DontDestroyOnLoad(this);
- }
- public void SaveCharacterData(){
- GameObject pc = GameObject.Find("pc");
- PlayerCharacter pcClass=pc.GetComponent<PlayerCharacter>();
- PlayerPrefs.DeleteAll();
- PlayerPrefs.SetString("Player Name",pcClass.Name);
- for(int cnt=0;cnt < Enum.GetValues(typeof(AttributeName)).Length;cnt++){
- PlayerPrefs.SetInt(((AttributeName)cnt).ToString()+ "- Base Value",pcClass.GetPrimaryAttribute(cnt).BaseValue);
- }
- }
- public void LoadCharacterData(){
- GameObject pc = GameObject.Find("pc");
- PlayerCharacter pcClass=pc.GetComponent<PlayerCharacter>();
- pcClass.Name= PlayerPrefs.GetString("Player Name","Name Me");
- for(int cnt=0;cnt < Enum.GetValues(typeof(AttributeName)).Length;cnt++){
- pcClass.GetPrimaryAttribute(cnt).BaseValue=PlayerPrefs.GetInt(((AttributeName)cnt).ToString()+ "- Base Value",0);
- }
- }
- }
Add Comment
Please, Sign In to add comment