Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. BinaryFormatter binaryFormatter = new BinaryFormatter();
  2. FileStream file = File.Open(Application.persistentDataPath + "/" + SceneManager.GetActiveScene().name + "Checkpoint.dat", FileMode.Open);
  3. CheckpointData data = (CheckpointData)binaryFormatter.Deserialize(file);
  4. data.Checkpoint = CheckpointNumber;
  5. Player.CheckpointNumber = CheckpointNumber;
  6. if (data.CheckpointUnlocked == CheckpointNumber - 1)
  7. {
  8. Player.CheckpointUnlocked = CheckpointNumber;
  9. data.CheckpointUnlocked = CheckpointNumber;
  10. }
  11. binaryFormatter.Serialize(file, data);
  12. file.Close();
  13.  
  14. BinaryFormatter binaryFormatter = new BinaryFormatter();
  15. FileStream file = File.Open(Application.persistentDataPath + "/" + SceneManager.GetActiveScene().name + "Checkpoint.dat", FileMode.Open);
  16. CheckpointData data = (CheckpointData)binaryFormatter.Deserialize(file);
  17. CheckpointNumber = data.Checkpoint;
  18. print(data.Checkpoint);
  19. CheckpointUnlocked = data.CheckpointUnlocked;
  20. print(data.CheckpointUnlocked);
  21. file.Close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement