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 disjuncted 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 bullcrap when it's so easy to do it properly. This entire project probably only took me 20 hours to complete. 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 in 2015.
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, arrgh.
- 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. I still have some more work to do here with a namespace perhaps and some other stuff, but it's a good starting point.
- 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. It even goes from zero to infinity, pretty much.
- 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. 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.
- Includes my brightness slider image effect which is the first image effect I've ever made. It's extremely simple, but still very useful. :p
- Subpixel Morphological Antialiasing (SMAA)
- Screen space reflections (SSR)
Some things I may add in the future, but you're welcome to add yourself:
- Blur the background behind the menu like on iOS. Shouldn't be too hard to do with some shader magic? If I were to do this I would keep the main panel open at the same time as the sub panels so the user gets a sense of depth in the menu as he navigates deeper into the panels.
- 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.
- Add tooltips to each setting describing what it does. Not many settings menus have these, and it's not exactly hard to implement.
- Add the option to remap controls, but Unity still doesn't offer this out of the box?
Some things I wanted to add, but Unity screwed me over:
- Soft particles can't be set through script.
- Shadow quality can't be set through script.
- Shadows ON, soft, hard can't be set through script.
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. There's some rough spots in there and the code is a bit messy as I was about to refactor it, but I didn't bother. I was thinking of putting it all into a namespace, but I've never tried that before so I'm postponing it for the next update or another project.
As usual you can download the entire project from the link on the right. 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.
- 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
- The scrollview will automatically scroll up/down if you move your mouse cursor over a slider that’s slightly out of view. It should only trigger when using gamepad or keyboard.
- If you have selected a preset and start changing the settings it still looks like you're using that preset. It should automatically switch to “Custom” if you change something in a preset.
- If you click something with the mouse and a slider appears behind the mouse cursor the mouse hover sound will override the click sound. Instead the click sound should play and the mouse hover sound should be ignored.
Possible future features
- Learn about namespaces so I can put the entire menu in a namespace and remove the GS_ prefix from everything.
- Learn about shaders and see if I’m able to blur what’s behind the menu like Apple does in their operating systems on iOS or OS X.
- Read up on saving/loading settings and see if I want to implement that, perhaps using player prefs?
- Upgrade the project to Unity 5.4 and include the Cinematic Image Effects.
- Look at implementing this: http://www.alanzucconi.com/2015/12/16/color-blindness