Skip to content

Instantly share code, notes, and snippets.

@JotaroS
Last active June 22, 2017 08:39
Show Gist options
  • Save JotaroS/be0081280d43df7908745756d4014d8e to your computer and use it in GitHub Desktop.
Save JotaroS/be0081280d43df7908745756d4014d8e to your computer and use it in GitHub Desktop.
Logs data of transform/rotation of the Gameobject
public class DataLogger : MonoBehaviour {
private StreamWriter sw;
private FileInfo fi;
private DateTime date;
// Use this for initialization
void Start () {
date = DateTime.Now;
}
// Update is called once per frame
void Update () {
string str;
string format = "yyyy-MM-dd-HH-mm-ss";
string filename = "/data/" + date.ToString (format) + ".csv";
fi = new FileInfo(Application.dataPath + filename);
str = this.gameObject + "," + (transform.position.x) + "," +(transform.position.y) + "," + (transform.position.z)+","+ transform.rotation.x +","+ transform.rotation.y +","+ transform.rotation.z +","+ transform.rotation.w ;
sw = fi.AppendText();
sw.WriteLine(str);
sw.Flush();
sw.Close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment