I’ve defined a static variable as “false” that gets accessed by several scripts. This works fine once (I’ve got it so if the user clicks a button, the variable changes and some script behaviors change).
However, after I stop the game mode and start it again for more testing, the variable, which has been set to “true” last time I ran the web player, starts out that way. I have to get Unity to recompile a script or restart it before the variable is back at its default.
Is there something special about static variables that mean changes made to them in game mode will last later on?
Whoa–major coincidence time! I literally just had that exact situation and was going to ask about it, though I already had figured out the Start function thing. Glad to know it wasn’t just me. (Love those useful bugs though. Much nicer than the other kind. )
I’ve made a live cameraedit recording script for intifada (you basically set up 10 cameras, let your cutscene play and then hit 1-0 to switch between them). t records the timing of all edits, and can then be read back in editor. I didn’t know about the statics (or forgot, or whatever), so I’ve been writing to a temp file. Can you say D’oh?
Although possibly a bit on the hackish side of things, I’d say it can be very useful.