In-game settings menu
This project is an example of how to setup an in-game settings menu in Unity. The main focus is on graphics settings, but I felt just having the graphics settings menu by itself would feel too disjoined so I included it as part of a full menu.
In the end this became very similar to the official Game Jam Menu Template available here:
But I think the two menus complement each other. There are some topics in the Game Jam Menu I didn't bother with and I have made no effort towards making this menu plug & play for whatever project you may have. I may consider that in the future, but for now I would get that part from the Game Jam Menu project.
With this project I focused on showing how you can handle in-game graphics settings in Unity. I've seen so many games, even released ones, who just give you the Unity game launcher with "Fast", "Good", "Fantastic" settings which is I think is lazy when it's so easy to do it properly. Unity even let's you adjust every single setting in real time without having to restart the game which some AAA games can't even do.
I also added a game scene as a background so you can instantly see what each setting does. I feel this is something every game should do so you're not just changing settings blindly. It should be immediately clear what each graphics setting does towards the final image. This project could also works as an image effect demo project I guess.
I've learned a lot through this project: About interacting with the new UI system through script, about inheritance and advanced coding topics, I've gotten my hands dirty with Unity events and I've really seen why the new audio mixer is useful. Overall this project has taught me a number of cool new things and I hope it does the same for you.
Here's some of the key features:
- Can be used with mouse, keyboard or gamepad. It probably works just fine with touch as well seeing as that is pretty much the same as a mouse.
- Let's you choose graphics presets or customize everything just the way you want it with what I feel is the most intuitive approach I've seen in any game. The game environment is visible at all times and every setting updates immediately giving you instant feedback on what it does.
- Every setting clearly shows what it's currently set to and what its min and max values are. No guesswork involved like in a lot of games where "Ultra" is the highest for some settings, but others just go to "High". Or games which only show the current setting with a previous/next arrow forcing you to click the next arrow for every single setting just to be sure they are maxed out, or even worse, doing so makes them loop back around to the lowest setting.
- The code is broken up into separate classes per graphics setting which lets you easily add new graphics settings and set their defaults per preset.
- A field of view slider which clearly states that it's vertical field of view, but also shows the current horizontal field of view for your screen setup. Total Biscuit would be proud.
- Audio sliders for everything you want which are mapped logarithmically to the audio mixer giving you a natural volume curve from min to max.
- Mouseover and click sounds for everything, and tick sounds when you increase/decrease the sliders.
- Keeps track of the selected UI element. Moving your mouse pointer over an element selects it for the keyboard so pressing up on the keyboard continues from that element. It also remembers which button you clicked to open a panel and selects it again when you return.
- The scroll view can be scrolled both with a keyboard and a gamepad, in addition to the mouse obviously.
- Includes my brightness slider image effect which is the first image effect I've ever made.
I feel like this is the best thing I've made in Unity so far and I hope you like it. I reached every goal I set for myself with this project, and that I extended the default capabilities of the Unity UI quite a bit. And even though I struggled a fair bit with the menu, I didn't end up hating the UI system as much as I thought I would. It's actually fairly solid.
As usual you can download the entire project. I hope you find a use for it and the only thing I ask in return is some critique on the project. I would love some feedback on my approach to the code structure, or just some input on what you feel could be solved better or differently in the menu itself.
I made a video showcasing version 2 of the menu here:
- Upgraded the project to Unity 5.6.7 and moved everything to Github.
- Upgraded the project to Unity 5.5.2.
- Replaced all the image effects with the new official post processing stack.
- Replaced the demo scene with the new version.
- Learned about namespaces and put everything in a namespace and removed the GS_ prefix from everything.
- Cleaned up the code a bit. There's less boiler plate per graphics setting now and it feels more robust.
- Added Pavel Dobryakov's awesome UI blur: /resources/apple-style-ui-blur
- It now automatically switches to the custom preset if you have selected a preset and changes one of the settings.
- Added a tooltip when you mouseover the UI elements.
- Upgraded the project to Unity 5.4.4.
- Added Windows and Mac standalone builds.
- Added a README.txt to the project.
- Upgraded the project to Unity 5.3
- Initial release
- Some of my class names and code structure made the code harder to use in a namespace.
- The code is still quite rough. For example the SliderBase base class is mainly dedicated to graphics functionality, but I use it for the volume sliders as well.
- I want the tooltip to show at a fixed position in relation to the element, but I
struggled with that and settled for showing it at the cursor's position instead.
- The tooltip doesn't disappear when you click a button if it's showing because the mouse out event isn't called.
- I forgot to take keyboard/gamepad navigation into account when I created the tooltip.
- Basically the tooltip is shit at the moment. :p
Possible future features
- Read up on saving/loading settings and see if I want to implement that, perhaps using player prefs?
- Look at implementing something like this: https://www.alanzucconi.com/2015/12/16/color-blindness/
- Add the ability to change resolution and fullscreen mode.
- Make it possible to rebind key bindings.
- Add a setting to toggle soft particles. Not sure if it's possible, it wasn't possible when I first started this project.
- Add a setting to set shadow quality. Not sure if it's possible, it wasn't possible when I first started this project.
- Add a setting to set hard or soft shadows through script. Not sure if it's possible, it wasn't possible when I first started this project.
- Modify the Outline script included with the UI system to make it possible to add rectangular outlines along the sides of UI elements. To add selection boxes. I think I prefer that over the pulsating background I have now.
- Hide the cursor when you press a button on the gamepad and show it again when you move the mouse.