Useful scripts for Quick 'n good UGUI
Hey folks - development of Maintenance Day "Full" is going along fine, got plenty of secrets to tease over the coming months I reckon.
Whilst I crack on, I wanted to share some useful scripts I'd made as I've been doing the main menu for the game. This has been my first real effort into making a menu that supports gamepad AND mouse, so it's been a learning experience for sure:
This all revolves around these 3 scripts and then a load of snazzy reactor scripts, here's one of my button reactors as an example.
Those scripts should be straightforward enough to parse how they work, here's how I've got my UI setup:
- Always set hidden/inactive UI gameobjects inactive (this is also a general perforamance tip: even if a bit of UGUI is offscreen/set to zero localScale, it causes you render batches)
- When a UI container/page is enabled (e.g. the settings tabs you see above), there should be one object with the FocusOnEnable component
- From there, use the built-in navigation options on UGUI, preferring to keep everything in one column, or using the explicit option to drive anything more complex
- Now, with the pointer being able to focus/unfocus based on hover, if nothing is selected, there should always be a SetFocusedIfNothingSelected component active to grab focus.
- Then, based on if an object is selected/not, use classes to react to that. In my case the menu is simple enough that I don't need to care about checking on Update.
You'll probably need to cleanup the Input system being used (either the old one, or Rewired, or whatever), but otherwise those 3 have been instrumental - and surprisingly simple once you get down to it.
Hope this helps anyone else!
Get A Day of Maintenance (Jam Version)
A Day of Maintenance (Jam Version)
A driving fix 'em up crane-operator game for 7DFPS
Status | Released |
Author | BigHandInSky |
Genre | Puzzle |
Tags | 3D, Atmospheric, crane, desert, Driving, fixing, maintenance, Open World, Sci-fi, Singleplayer |
Languages | English |
Accessibility | Color-blind friendly, Subtitles, High-contrast, Interactive tutorial |
More posts
- Site Update Teaser - The Sunken DishJun 07, 2021
- Validating Unity Builds the easier wayMay 15, 2021
- Working on the game's IntroductionApr 20, 2021
- Character TeaserMar 30, 2021
- Improving the Vehicle CameraMar 20, 2021
- Adding world propsFeb 21, 2021
- A helpful Ink-Knot PropertyDrawerFeb 07, 2021
- Things you should know before making a Vehicle in UnityJan 30, 2021
- A sneak peek at what's comingJan 01, 2021
Leave a comment
Log in with itch.io to leave a comment.