You could always create one script called "SaveData" or something similar and have this in it
using UnityEngine;
using System;
public class SaveData : MonoBehaviour {
public void SaveCharacterData() {
GameObject pc = GameObject.Find("pc");
PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
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);
PlayerPrefs.SetInt(((AttributeName)cnt).ToString() + " - Exp To Level", pcClass.GetPrimaryAttribute(cnt).ExpToLevel);
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Base Value", pcClass.GetVital(cnt).BaseValue);
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Exp To Level", pcClass.GetVital(cnt).ExpToLevel);
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Current Value", pcClass.GetVital(cnt).CurValue);
// PlayerPrefs.SetString(((VitalName)cnt).ToString() + " - Mods", pcClass.GetVital(cnt).GetModifyingAttrituesString());
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
PlayerPrefs.SetInt(((SkillName)cnt).ToString() + " - Base Value", pcClass.GetSkill(cnt).BaseValue);
PlayerPrefs.SetInt(((SkillName)cnt).ToString() + " - Exp To Level", pcClass.GetSkill(cnt).ExpToLevel);
// PlayerPrefs.SetString(((SkillName)cnt).ToString() + " - Mods", pcClass.GetSkill(cnt).GetModifyingAttrituesString());
}
}
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);
pcClass.GetPrimaryAttribute(cnt).ExpToLevel = PlayerPrefs.GetInt(((AttributeName)cnt).ToString() + " - Exp to Level", 0);
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
pcClass.GetVital(cnt).BaseValue = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Base Value", 0);
pcClass.GetVital(cnt).ExpToLevel = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Exp to Level", 0);
//make sure you call this so that the AdjustedBaseValue will be updated before you try to call to get the curValue
pcClass.GetVital(cnt).Update();
//get the started value for the curValue for each vital
pcClass.GetVital(cnt).CurValue = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Cur Value", 1);
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
pcClass.GetSkill(cnt).BaseValue = PlayerPrefs.GetInt(((SkillName)cnt).ToString() + " - Base Value", 0);
pcClass.GetSkill(cnt).ExpToLevel = PlayerPrefs.GetInt(((SkillName)cnt).ToString() + " - Exp To Level", 0);
}
//output the curValue for each of the vitals
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
Debug.Log(((SkillName)cnt).ToString() + ": " + pcClass.GetSkill(cnt).BaseValue + " - " + pcClass.GetSkill(cnt).ExpToLevel);
}
}
}
I apologize for all the stuff in there those are just what determines my skills/vitals...
If you want to learn how to set up those check out the tutorial by BurgZergArcade on youtube...
Im not going to give you a link to his videos for two reasons...
It helps to start from the beginning of his tutorials to set this up...
You can just go to his channel which is BurgZergArcade.
I apologize if this doesn't help because of all you have to do to get it to work but i tried...