Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System;
- using System.Collections;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Runtime.Serialization;
- using System.Runtime.Serialization.Formatters.Binary;
- [Serializable()]
- public class GameData
- {
- #region Fields
- private GameManager manager;
- private int score;
- #endregion
- #region Properties
- #endregion
- #region functions
- void Start()
- {
- manager = (GameManager)GameObject.FindObjectOfType(typeof(GameManager));
- score = manager.score;
- }
- public static void SaveThisGameData()
- {
- //serialize the game data here
- FileStream fs = new FileStream("Game.Data", FileMode.Create);
- BinaryFormatter bf = new BinaryFormatter();
- bf.Serialize(fs, manager.score);
- fs.Close();
- }
- public static void LoadThisGameData()
- {
- //deserialize the game data here
- FileStream fs = new FileStream("Game.Data", FileMode.Create);
- BinaryFormatter bf = new BinaryFormatter();
- score = (int) bf.Deserialize(fs);
- fs.Close();
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement