- Home /
Strategy for 'recording' data
I am working on a 2d platformer that is heavily physics based, and I am trying to figure out the best way to record motion tracers during a play phase such that when I stop the game the editor has a recorded path shown.
Scripting this for runtime is pretty straight forward, I have a script that ticks every x seconds adding the transform.position data to a List, but I am curious what strategies there are for piping that data back into the editor so I can adjust platforms after I hit stop.
Answer by Waz · Jul 15, 2011 at 05:58 AM
PlayerPrefs is persistent and easily accessible both in-game and in the Editor. Flatten your list into a string, store it in a key, and Split it back up later later. Or if you want to get fancy, use .NET Serialization.
Answer by Waz · Jul 15, 2011 at 06:03 AM
For transient data, you can get away with a global variable - these persist after game execution, until the next time that compilation unit is reloaded.
Yeah, I was hoping to avoid dealing with file I/O, I could use the PlayerPrefs as convenience though but will be the way to go. Ill just have an editor button that sucks in the 'last run'
Im curious about your transient data suggestion, c# doesn't have global variables, do you mean a singleton class ? I haven't seen any runtime data persist
Have a class variable with data in it and access it in OnDrawGizmos, you should find it persists after running in the editor.