Virtual Game Lab
  • News
  • Research
  • Publications
  • Unity Resources
  • Contact

Saving text files in Unity

5/30/2010

8 Comments

 
One of the most important things for me whenever I use Unity for any experiment is the ability to store lots of information on my hard drive. I record every aspect of the program, locations and timings of events, recordings of movements and anything that could be of importance later on. By saving to a text file, it is really easy to export that recorded information into any statistical program for analysis. I created two short scripts (using JavaScript) and a video which explains their use. Feel free to send me questions and comments.
The example in the video is only meant to demonstrate the general use of these scripts for saving information. I cannot guarantee that this is the most elegant or optimized method for saving to a text file, but it worked for me in many projects so far. You can literally save anything you want and trigger the saving process with whatever you want (Triggers, Time, Button Clicks, Quitting the application, User actions, etc.). Loading information into Unity from text files is just as easy with a very similar process. The "save.js" script handles both. With loading data  into your environment it's very simple to visualize your results after the experiment (or game session) is done.

-Sebas

HD version of the video tutorial and the two Javascript scripts for download
unity_saving_hd.mp4
File Size: 29638 kb
File Type: mp4
Download File

save.js
File Size: 0 kb
File Type: js
Download File

saveobject.js
File Size: 0 kb
File Type: js
Download File

8 Comments
johnny link
2/18/2012 02:09:57 am

hallo, i wont to know how to make the load function working, i tried the function from save.js Save.LoadTextFile(fileFolder+fileName+".txt"); but it didnt work.
can you help?

Johnny

Reply
cam
5/4/2012 02:36:22 pm

i get an unknown identifier "save" compile issue

Reply
Afon
3/19/2013 08:59:19 am

change file name to Save, with a S not a s

Reply
me
8/15/2012 12:12:48 am

Save.LoadTextFile(fileFolder+fileName+".txt")

should be lowercase "save"
save.LoadTextFile(fileFolder+fileName+".txt")

Reply
tonie
2/28/2013 06:50:03 pm

looks like a good start for my saving thing in editor.

Reply
kashif
7/30/2014 06:52:19 am

HI Can You please guide , how can i reuse that data which has been saved into the text file to redo the same simulation which had been performed ...


Please Help

Reply
Lindsay
9/17/2014 10:20:16 am

Awesome file, thanks a lot. I was wondering if their was a way to increase the significant figures shown in the text file?

Reply
Lindsay
9/17/2014 10:28:13 am

dw, you do it like this.

ToString("#.00");

Reply



Leave a Reply.

    Sebas

    Experimental Psychologist
    Research Associate

    Mad Scientist

    Red 5 Studios
    Institute for Creative Technologies, USC, Los Angeles

    View my profile on LinkedIn

    RSS Feed

    Archives

    January 2013
    December 2012
    November 2012
    September 2012
    June 2012
    April 2012
    March 2012
    January 2012
    July 2011
    June 2011
    May 2011
    April 2011
    January 2011
    December 2010
    October 2010
    August 2010
    July 2010
    June 2010
    May 2010
    April 2010

    Categories

    All
    Development
    Games User Research
    Literature
    News
    Research Update
    Unity
    Unity Research Update
    Virtual Reality

© Copyright Sebastian Koenig 2009-2018