public static void SaveZustand(TestZustandPlayer opa) { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/zustand.zs", FileMode.Create); ZustandData data = new ZustandData(opa); bf.Serialize(stream, data); stream.Close(); Debug.Log("ZS-GESPEICHERT"); }
public static void LoadZustand(TestZustandPlayer opa) { if (File.Exists(Application.persistentDataPath + "/zustand.zs")) { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/zustand.zs", FileMode.Open); ZustandData data = bf.Deserialize(stream) as ZustandData; stream.Close(); opa.getAlkohol = data.alkohol; opa.getAngst = data.angst; opa.getGier = data.gier; } else { Debug.LogError("ZS-File does not exist"); opa.getAlkohol = 0; opa.getAngst = 0; opa.getGier = 0; } }