I'm using this code to make sure the keys are in the file.
Save function
Code: Select all
void Save(){
dataFile.Save<samplePlayerData>("PlayerData", PlayerData);
dataFile.Save<string>("myName", this.name);
dataFile.Save<Transform>("myTransform", transform);
string sample = "";
foreach (string s in dataFile.GetKeys())
{
sample += " Key: " + s;
}
print("Size: " + dataFile.Size() + sample);
}
Code: Select all
public class samplePlayerData: MonoBehaviour
{
public string key1 = "";
public int value1 = 0;
public bool bool1 = false;
public float value2 = 0;
public string key2 = "";
public bool bool2 = true;
public Vector2 vector1 = new Vector2(0, 2);
public string key3 = "";
public Vector3 vector2 = new Vector3(3, 4, 1);
public void GenerateValues()
{
key1 = Path.GetRandomFileName();
value1 = Random.Range(0, 100);
bool1 = false;
value2 = Random.value;
key2 = Path.GetRandomFileName();
bool2 = true;
vector1 = new Vector2(Random.Range(0, 100), Random.Range(0, 100));
key3 = Path.GetRandomFileName();
vector2 = new Vector3(Random.Range(0, 100), Random.Range(0, 100), Random.Range(0, 100));
}
}
Code: Select all
Size: 706 Key: PlayerData Key: myName Key: myTransform
UnityEngine.MonoBehaviour:print(Object)