Jump to content
  • Advertisement
Sign in to follow this  
malo88

Unity [UI] Help building a controller info bar

This topic is 452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone. 

I'm developing a PC game with Unity and I have a code design question about the GUI. I'm trying to build an UI system for all my menus in games which gives you the available buttons you can press on this scree. It's like a bar at the bottom of the screen (see pictures attached), which changes every time you change screen and there are different buttons to press. The thing is, I have to switch between PC layout and controller layout. So for example if you plugin a controller it must show you the same actions, but mapped to the controller buttons (see pic ),

[attachment=35509:console.png]

and if you press the keyboard or use the mouse it automatically switch to PC actions (see pic).

[attachment=35508:pc.png]

This kind of bar must be maintained valid every time the gui is on screen and so it should "listen" to all the available inputs and mapped actions. 

First of all: do this kind of bar has a common name (so I can look for example myself)? Do you know if there is well known pattern to implement this?

Thanks guys!

Share this post


Link to post
Share on other sites
Advertisement

Bear in mind that a UI that changes to reflect the game state is a pretty standard concept - whether that's a set of buttons, or a health bar, or whatever - so you wouldn't expect to find a special name for such a thing. The pattern for handling them is quite simple; when the game state alters in a way that might be relevant for the UI element, you tell the UI to update, and then the elements can query the game state to see whether they need to look different (in this case, switching to showing controller buttons).

Share this post


Link to post
Share on other sites

Thank you guys, sorry for the late answer!

Actually I'm already using Rewired, so I managed to do as cmac suggested.

@Kylotan: you are talking about the MVC pattern I imagine, so yes, I did something like that. The controlbar has a logic and a listener: the listener receives the inputs active at the moment and tells the logic about them. The logic then tells the view (the real Gameobject) to show the buttons icons and labels corresponding to the active actions!

Many thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!