Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Runtime.Serialization.Formatters.Binary;
- using UnityEngine;
- using System.IO;
- public static class SaveAllGameProgress
- {
- public static void SaveZaino(DontDestroyAmmo DDA){
- BinaryFormatter bf = new BinaryFormatter();
- string path = Application.persistentDataPath + "/saveInvetoryAmmo.obi";
- FileStream stream = new FileStream(path, FileMode.Create);
- SaveZaino sz = new SaveZaino(DDA);
- bf.Serialize(stream, sz);
- stream.Close();
- }
- public static SaveZaino loadZaino()
- {
- string path = Application.persistentDataPath + "/saveInvetoryAmmo.obi";
- if (File.Exists(path))
- {
- BinaryFormatter bf = new BinaryFormatter();
- FileStream stream = new FileStream(path, FileMode.Open);
- SaveZaino sz = bf.Deserialize(stream) as SaveZaino;
- stream.Close();
- return sz;
- }
- else
- {
- Debug.LogError("Save not found in: " + path);
- return null;
- }
- }
- //MEDIKIT
- public static void SaveZainoMedikit(DontDestroyMediKit DDM)
- {
- BinaryFormatter bf = new BinaryFormatter();
- string path = Application.persistentDataPath + "/saveInvetoryMedikit.obi";
- FileStream stream = new FileStream(path, FileMode.Create);
- SaveZainoMedikit szm = new SaveZainoMedikit(DDM);
- bf.Serialize(stream, szm);
- stream.Close();
- }
- public static SaveZainoMedikit loadZainoMedikit()
- {
- string path = Application.persistentDataPath + "/saveInvetoryMedikit.obi";
- if (File.Exists(path))
- {
- BinaryFormatter bf = new BinaryFormatter();
- FileStream stream = new FileStream(path, FileMode.Open);
- SaveZainoMedikit szm = bf.Deserialize(stream) as SaveZainoMedikit;
- stream.Close();
- return szm;
- }
- else
- {
- Debug.LogError("Save not found in: " + path);
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement