sttz / trimmer

An editor, build and player configuration framework for the Unity game engine.
MIT License
104 stars 8 forks source link

Where does PlayerPrefs fit in? #2

Closed JesseTG closed 1 year ago

JesseTG commented 5 years ago

I've managed to figure out that not only is Trimmer designed to be used to configure builds, but it can also be used to configure the game at runtime. In fact, it even provides INI support as an Option.

But I don't want to store my game's configuration in an INI; I just want to use PlayerPrefs. Should I create a special OptionPlayerPrefs similar to your OptionIni? Or should I just make my custom Options directly interact with PlayerPrefs?

sttz commented 5 years ago

I think Trimmer and PlayerPrefs serve different purposes.

Trimmer is intended for development options, helping you create different types of builds and to also reconfigure builds where that makes sense. It was always the idea that, for the final release build, you could remove all Options and have Trimmer virtually be compiled out.

This is also reflected in the name Trimmer: https://en.wikipedia.org/wiki/Trimmer_(electronics) A small component that allows tweaking a product but which is not really intended for the users to touch.

PlayerPrefs, on the other hand, contain the user configuration. Game settings, control remappings, game progress etc.

You could use Trimmer for user configuration as well but there's nothing built-in that allows you to save changes made to Options at runtime. You could create an Option that loads and saves the RuntimeProfile's Store from and to PlayerPrefs but I haven't tested how well round-tripping works in this case.

JesseTG commented 5 years ago

How do you personally use Trimmer in practice, then? What kinds of things do you use it to configure in your own games? (Same for anyone else you know who uses this.)

sttz commented 5 years ago

We use it to enable debug features (logging, cheats, invincibility, fps display etc), exhibition-related options (unlock all, different menu structure, idle reset) and the various integrations (Steam, GOG, IAP, Game Center, Google Play etc). We also use it to tweak volume and the fps limit, which could be exposed as user options but we haven't.

On the other hand, user options like fullscreen, resolution, quality, language, input overrides etc are stored in PlayerPrefs and gameplay-related stats like progress, unlocks and achievements are stored in PlayerPrefs or in the respective cloud storages.

I see that it could make sense to have Options for those as well but there's currently nothing in Trimmer to make that work. One question would be precedence, if something is set both via Trimmer and PlayerPrefs, which value do you prefer?

One case where we have something like this implemented is for unlocks: The player's unlocks are stored in PlayerPrefs/cloud storage but there's an Option to override it. The Option just sets a forceUnlock variable that then overrides whatever is set in PlayerPrefs.

JesseTG commented 5 years ago

Ah. That makes perfect sense. I think I was under the assumption that Trimmer was designed to be used for runtime player configuration, given that some of the features appear to be suited for that but not really.

Maybe the documentation could have more information about what Trimmer is and isn't intended to be used for?

sttz commented 5 years ago

I think Trimmer could definitely be extended to support runtime configuration as well, it's just not what I've been using it for. Though, I would want this to stay optional, so that people who prefer to use Trimmer as a build-only framework can continue to do so.

I'm still thinking about simplifying some of the concepts and the documentation, which would hopefully also make it clearer how Trimmer can be used.