I want to create a method of recording what is happening in my drum game, like a midi file where every time a certain drum is played the time it has been played is recorded to a text file in real time and then read back. The problem I have is adding a new line without overwriting the entire file.
In Response to the answers, I tried,
import System.IO;
var sw = new StreamWriter("TestFile.txt");
function Start () {
}
function Update () {
if (Input.GetButtonDown("keyOne")) {
sw.WriteLine(Time.time);
}
if (Input.GetButtonDown("keyTwo")) {
sw.Close();
}
}
But nothing was written at all? And Erics answer, how do you use the append option? Sorry about this but i can't seem to find any IO documentation using JS. :'(
The first code sample is failing (unknown identifier "sw") because you have sw declared locally in the Start function instead of globally. When the Update function calls on sw it has no idea what it is because it's only been locally declared.
In your second code you declare sw once locally in the Start function and a second time locally in the Update function, so essentially it's two different variables. Try declaring it globally and see if that helps.