Some variables are handy for setting up a game, but are not useful during gameplay itself. How do you handle that?
I’m not sure what you mean – if you need them, they’re useful
Can you give an example?
I am picturing you mean during Phase A you need certain variables but not during other phases? If this is true, my first question would be: so what?
My input though would be that maybe you need to look at refactoring your code a bit. If you need to setup a bunch of ObjectA objects and they have a bunch of variables just for the setup and are ignored after you may want to make an ObjectAFactory type object that holds all the data for setting up. Once done you can remove the Factory.
There are some variables that are useful to developers but not the game. For example, I want to have two floats, to define the lowest and highest opacity that an object may obtain. In-game, the opactiy of an object will be equal to:
lowest + (highest-lowest) * aSineWaveOrSomething
“(highest-lowest)” can be stored in a float. so “highest” is useless in-game.
Another case is, I want to drag a bunch of textures to variable slots in the Editor, and have an atlas made. Only the atlas is useful in-game. Not the individual textures.
The current method I’m trying involves using a script to set up in-game variables, using a menu item, based on these useless-at-runtime variables. Then, before I build, I save a new scene with this setup script removed. It works, but it’s kind of a pain.
Are you concerned about the memory footprint of these variables? To be honest, you would only notice the difference on the iPhone, and even then only if you had a lot of string data (say a complex conversation engine where all the strings were preprocessed before use).
Not really, because my old method was to Destroy scripts in Awake/Start. But that’s not particularly efficient, if the Start() code can be performed in the Editor instead, and it makes the code messier.
I only use Unity iPhone, anymore.
My first example was just a very simple case - no noticeable difference would come of that, but it illustrates the point. However, if you use a lot of PackTexture functions, then, even if you Destroy the textures immediately, for a moment, you’re going to be taking up twice as much memory for each packed texture as necessary. That could make an iPhone game un-runnable. It also would slow down the start of the game, and as a player, I’d hate that.