Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using System.Runtime.Serialization.Formatters.Binary;
  2. using UnityEngine;
  3. using System.IO;
  4.  
  5.  
  6. public static class SaveAllGameProgress
  7. {
  8. public static void SaveZaino(DontDestroyAmmo DDA){
  9. BinaryFormatter bf = new BinaryFormatter();
  10. string path = Application.persistentDataPath + "/saveInvetoryAmmo.obi";
  11. FileStream stream = new FileStream(path, FileMode.Create);
  12. SaveZaino sz = new SaveZaino(DDA);
  13. bf.Serialize(stream, sz);
  14. stream.Close();
  15. }
  16.  
  17.  
  18.  
  19. public static SaveZaino loadZaino()
  20. {
  21. string path = Application.persistentDataPath + "/saveInvetoryAmmo.obi";
  22. if (File.Exists(path))
  23. {
  24. BinaryFormatter bf = new BinaryFormatter();
  25. FileStream stream = new FileStream(path, FileMode.Open);
  26.  
  27. SaveZaino sz = bf.Deserialize(stream) as SaveZaino;
  28. stream.Close();
  29. return sz;
  30. }
  31. else
  32. {
  33. Debug.LogError("Save not found in: " + path);
  34. return null;
  35. }
  36. }
  37.  
  38.  
  39.  
  40.  
  41. //MEDIKIT
  42. public static void SaveZainoMedikit(DontDestroyMediKit DDM)
  43. {
  44. BinaryFormatter bf = new BinaryFormatter();
  45. string path = Application.persistentDataPath + "/saveInvetoryMedikit.obi";
  46. FileStream stream = new FileStream(path, FileMode.Create);
  47. SaveZainoMedikit szm = new SaveZainoMedikit(DDM);
  48. bf.Serialize(stream, szm);
  49. stream.Close();
  50. }
  51.  
  52.  
  53. public static SaveZainoMedikit loadZainoMedikit()
  54. {
  55. string path = Application.persistentDataPath + "/saveInvetoryMedikit.obi";
  56. if (File.Exists(path))
  57. {
  58. BinaryFormatter bf = new BinaryFormatter();
  59. FileStream stream = new FileStream(path, FileMode.Open);
  60.  
  61. SaveZainoMedikit szm = bf.Deserialize(stream) as SaveZainoMedikit;
  62. stream.Close();
  63. return szm;
  64. }
  65. else
  66. {
  67. Debug.LogError("Save not found in: " + path);
  68. return null;
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement