예제 #1
0
        public static void Load()
        {
            // Load the graph object from a file
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      fs        = File.OpenRead(Application.persistentDataPath + "/testsavedata.sb");
            object          graph     = formatter.Deserialize(fs);

            fs.Close();

            //Debug.Log(graph.ToString());

            // Retrieve the data we saved
            TestSaveData sd = (TestSaveData)graph;

            Debug.Log(sd.ToString());
        }
예제 #2
0
        public static void Save()
        {
            object graph = null;

            // Define what we will save
            TestSaveData sd = new TestSaveData(10);

            sd.f  = 5.23f;
            sd.s  = "ciao";
            graph = sd;

            // Save the graph object to a file
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      fs        = File.Create(Application.persistentDataPath + "/testsavedata.sb");

            formatter.Serialize(fs, graph);
            fs.Close();

            Debug.Log("SAVED");
        }