- Home /
Prefered method for custom game settings?
I've started implementing some custom game settings for my game, eg. dynamic weather shifting, displaying particle emitters on quest items and blood effects when killing creatures. Most of my own settings are set when the games levels load so there's no problem there but in some cases, as the blood-effects for example, I have to check every time a ragdoll is instantiated since that's the gameobject I've set to activate such particles.
From a performance perspective, what would be best method to use, using delegates and a switch-case or having the ragdoll-script load the setting for blood, read if it's on or off and perform action depending on that.
As said many times before, I'm new to coding so if you know some other or perhaps a more efficient method I'ld appreciate it alot if you'd share an API or a tutorial or something along those lines on how to use it so I could learn. :)
(Edit: by the way, the settings are loaded from playerprefs and stored into a gameobject with my script attached to it on Start(), so all settings are loaded at start but still a few objects in the game will need to check what those settings are after Start(), as mentioned before the ragdolls for example. <- thought I'ld add this since perhaps it's a better explanation.)
Answer by Waz · Jun 29, 2011 at 06:29 AM
Provided you push the setting save/load to where its not done every frame (just when they change, and stored in statics), your performance should be fine if the each lookup is a direct bool or enum check. I don't see any value in having save/load dispersersed across the setting users since ultimately you still have to pull them all together for your settings dialog anyway.
This sounds like what you're doing already, but to be clear, users of the settings should be doing no more than:
if (Settings.blood)
bloodParticles.Emit(Settings.bloodiness);
They should not be doing:
if (Setting.Find("blood").ToBool())
bloodParticles.Emit(Settings.Find("bloodiness").ToInt());
Your answer
Follow this Question
Related Questions
custom event delegate - convertible error 3 Answers
Editor Window with settings and Asset Creation 1 Answer
How to add comments or instructions above a field in the inspector? 2 Answers
Creating custom mipmaps on Mac 0 Answers
2 splash screens? 1 Answer