Jump to content
target_practice

disableSerialization (or lack thereof)

Recommended Posts

I have been developing a number of scripts which involve storing UI elements as variables.

I realised a while into their development that I've been forgetting to make use of disableSerialization, but despite this the scripts run without any issue, or even any errors.

 

Simply put, how is this the case? Is there some kind of hidden consequence of not using the command?

Share this post


Link to post
Share on other sites

Not using disableSerialization, my experience is, if you're storing UI elements in variables contained in a loop they work until you save, exit out and reload the saved game.  You load the saved game and the UI variables come back nil.  Causes errors.  If defined within a script being called, spawned, etc. (not part of a loop), they may work.  But sometimes not.  Using disableSerialization prevents the script from saving, and therefore it won't run when the loaded save is played (prevents errors).  It's something about, you can define (store) a UI element in a variable, but you cannot save a UI element in a variable.  They're not persistent in a reloaded saved game.

 

But I don't fully understand disableSerialization myself and look forward to hearing from others with knowledge.  I'm just starting to delve into UI namespace.  Some UI's I'd like to keep up after reloading a save, and I find disableSerialization in their scripts.

  • Thanks 1

Share this post


Link to post
Share on other sites

If that's the only consequence, then it doesn't cause me any problems specifically as aforementioned scripts are part of a multiplayer gamemode I'm developing, but I'll still try to ensure I use it from now on to be safe.

On a bit of a tangent though, is it really true that save games contain both active scripts and their state at the time the game is saved? Because I didn't know that.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×