To read I have this code
public static int LevelOn = 1;//highest level unlocked
public TextAsset textFile;
void Update()
{
string text = textFile.text; //this is the content as string
byte[] byteText = textFile.bytes; //this is the content as byte array
LevelSelect.LevelOn = int.Parse(text);
}
And to Write have this code
File.WriteAllText (Application.dataPath + "\\Resources\\currentLevel.txt", LevelSelect.LevelOn.ToString ());
But it takes a few minutes to actually load to the txt file. but if I stop running unity and open the txt it wrights to it.
How can I make it instantly wright to the txt file?