Closed basisbit closed 5 years ago
I have a few questions before I get started
Question1: Is there a documentation of settings(list of available setting keys with parameters)? If not I can create such a list based on ESettings.cs and initial values in GameSettings.cs, but where to put it, wiki?
Question2: My plan would be to implement this feature using persistentDataPath but what kind of data format would you prefer xml, json?
Question3: Are we planning to add some backward compatibility ( f.e in version 1.0 there is ESetting.TopScores and in version 1.1 we renamed it to ESettings.HighScores) Do we want to copy old settings values and fix the settings file to new version(contain only currently supported setting keys) or we just set it to default if we didn't find it in old settings file?
Question4: Does settings get saved after any changes or should user decide when he want to save changes or restore defaults?
Question5: Is there a template/style sample for settings value inputs (labels and textboxes, sliders,etc) because I didn't find any, so I'm guessing I should come up with something, correct?
wow, so many questions, and this project just started a couple of days ago 😄
When looking at Performous or Stepmania, you might see that too many changeable settings easily frustrate new or occasional users of such software. Thus, at least initially for the first versions until we have some users feedback, please don't add "all the possible settings" to the UI yet.
I messed around with a settings implementation in a branch on my fork. It's far from finished yet, but the goals I set myself were:
To achieve this, it uses Unity's PlayerPrefs thing and a bunch of abstract classes so that, for example, having a setting for Language literally means creating an enum class for the possible values (duh) and a class to actually use that as a setting, like this:
public class DisplayLanguageSetting : SimpleEnumSetting<ELanguage>
{
protected override ELanguage GetDefaultValue()
{
return ELanguage.English;
}
}
The parent classes have some public methods to Get()
or Set(ELanguage newLanguage)
the value, and Set(...)
also immediately saves. There is also a more complex example of a List
Some measure of error handling should also still be added (example: French used to be a supported language, but now it isn't anymore, it should just default back to whatever is the current default).
Numeric settings can probably also have stuff like minimum, maximum and step things.
I'm not sure if some/all of the current setting methods (like Get
and Set
) should be made static
or not, assuming that is even possible.
My own thoughts on the 5 questions and answers in the above posts:
Set
(or, in the case of the List one, also on Add
and, if necessary, on Remove
)As an aside, there should probably be a 'factory reset everything' command line option that just deletes any and all saved settings, regardless of whether they're still relevant or from some really old version. Maybe in a later version we'd split that into a 'wipe settings' and a 'wipe all highscores/players', but for a first version just deleting everything is fine I think.
I did some more work on this, and even wrote a few tests, in my fork. As a proof of concept and extensibility, I think it does a fine job, though I couldn't get the IList
Although I'm not too fond of the way it's currently done, also notice that the SimpleEnumSetting will survive game upgrades. It isn't too hard to do something similar for numeric values as well (min/max/step), but this is the point where I'd like some general feedback first before implementing half a dozen classes.
This has been done in #57
Actual behaviour
Changes to game settings are lost after user closes the game.
Expected behaviour
The game stores changes to settings. Settings survive game updates.
Steps to reproduce