public static StoryManager.StoryProcess LoadStoryProcess() { string path = Application.persistentDataPath + "/StoryProcess/" + "Process" + ".pro"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); stream.Position = 0; StoryManager.StoryProcess data = new StoryManager.StoryProcess(); stream.Seek(0, SeekOrigin.Begin); data = formatter.Deserialize(stream) as StoryManager.StoryProcess; stream.Close(); return(data); } else { Debug.Log("<color=red>Load Error</color>"); return(null); } }
//------------------------------- //StoryProecss-------------------- public static void SaveStoryProcess(StoryManager.StoryProcess _process) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/StoryProcess"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += "/" + "Process" + ".pro"; FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); stream.Seek(0, SeekOrigin.Begin); formatter.Serialize(stream, _process); stream.Close(); stream.Dispose(); }