Created
January 2, 2015 08:00
-
-
Save swt02026/3126ba0e849a3086f723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.IO; | |
public class SceneStorer { | |
static readonly string FILENAME = Application.persistentDataPath+"/"+"scene"; | |
static public void WriteToFile(int sceneID){ | |
//TODO | |
using(FileStream fs = new FileStream(FILENAME,FileMode.Create,FileAccess.Write)){ | |
using(StreamWriter stream = new StreamWriter(fs)){ | |
stream.WriteLine(sceneID.ToString()); | |
} | |
} | |
} | |
static public int GetSaveLevel(){ | |
if(File.Exists(FILENAME)){ | |
return int.Parse( File.ReadAllText(FILENAME)); | |
} | |
return -1; | |
} | |
static public int ReadFromFile(){ | |
//TODO | |
using(FileStream fs = | |
new FileStream(FILENAME,FileMode.OpenOrCreate,FileAccess.ReadWrite)){ | |
using(StreamReader stream = new StreamReader(fs)){ | |
string content = stream.ReadLine(); | |
if(content==null){ | |
using(StreamWriter wstream = new StreamWriter(fs)){ | |
return -1; | |
} | |
} | |
else{ | |
return int.Parse( content); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment