Hot answers tagged

80

I'd argue that HUDs are graphical user interfaces: they're ways to present information back to the user graphically. In contrast to what some other answers say, the term GUI doesn't require that every element be directly interactive - the label next to a control on a form is still part of the GUI, guiding the player in how to interact with the system, even ...


34

As someone with five or six years of actual experience with IMGUI on the desktop, I feel obligated to defend it. All of the responses (and the question itself) are based on a very restricted definition of IMGUI, and there seem to be a lot of questionable claims being made. A lot of it originates from the assumption that an IMGUI library can't retain any ...


34

Nay. I've done paid gamedev work on an awful 'retained mode' GUI and on an awful 'immediate mode' GUI and although both made me want to tear my eyes out, the retained mode approach is still clearly the better one. The downsides of immediate mode are many: they don't make it easy for artists and designers to configure the layout; they make you mix logic ...


26

Interactivity. A HUD is not interactive: it displays information only, it cannot be clicked, dragged, closed, etc. A GUI in a game is like any other UI: it is interactive. It has menus, buttons, scrollbars and other UI elements. The term Head Up Display refers to fighter jets: displaying information on a canopy means that the pilot does not need to look ...


23

There's a super simple way to change events: EDIT See my other answer for the quick and easy way to add an event for the OnClick event only. For other events, like OnDrag see below. Additionally, if you need more than just the events provided by default, I'd suggest instead attaching a EventTrigger to your game object. This gives us access to the ...


22

Most answers have addressed the feasibility of using heart container systems, I'd like to present a reason why you would want to use them over a health bar. Here's a word for you: Subitizing. People can make near-immediate judgments about the number of items in a group if you keep that number round about 4. Once you go above that point confidence and ...


21

I don't know of any particular icons, but I think the most important thing to keep in mind is that players associate the colour blue with magic. Thus, I don't think the icon actually matters, as long as you follow the basic convention of red for health, blue for magic and green (or the less-used yellow) for a third metric (usually stamina, but can be other ...


18

Okay, you're going to have to forgive me for not giving you specific XNA code, because I'm not knowledgeable in that platform, but what I'm going to tell you should work on any game engine that lets you draw sprites. Fonts is not your only problem, so I'm going to give you a piece of advice, and then I'm going to answer your question. With these two things, ...


17

If the health can grow significantly over the course of the game, I think that health bars are more appropriate. For example, in my current mmo game, the characters starts with 300 health, but that health can grow to over 3000 as the player levels. If this were implemented as hearts, it means you might start with one heart but have 10 or more hearts ...


17

Why not do both? You can have a health bar divided on discrete intervals. That has a lot of the advantages of both systems: You can make health increases be always an extra block. After you get hit, you know how much of a block an attack takes and it's easier to measure how many hits you can take. You can choose whether to make the bar longer or the blocks ...


15

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). It is defined that 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your ...


13

Finally I found a way to do it (tested in v5.0.0), in a way that: Does not need code, or conditionals to check orientation. Does not hack with scales and neither needs a reference resolution. In the UI video tutorials, there is a big part missing, although well documented in the text-documentation: The "auto-layouts" system. Auto-layouts are mechanisms ...


12

You can implement IPointerEnter and IPointerExit interfaces and keep boolean for 'over state': using System; using UnityEngine; using UnityEngine.EventSystems; public class TestOver : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { public bool isOver = false; public void OnPointerEnter(PointerEventData eventData) { Debug....


12

I personally only see it as being bad for two reasons: It is very outdated and deprecated. And, It is much slower than the modern ways of drawing with OpenGL. But, if it's working out, and performance isn't going to be an issue, and if it is not a problem for you to use deprecated OpenGL functions in your program, then I believe you could do it. It will be ...


11

The GUI library consists of one-shot "RenderButton", "RenderLabel", "RenderTextBox"... functions that you can call to "immediately" render a control (doesn't have to be immediately written to the GPU. Usually its remembered for the current frame and sorted into appropiate batches later). I would go so far as to say that this doesn't constitute a GUI library....


11

The word is that the delegate{} syntax found in my previous answer is obsolete, there is another way of doing this using lambda notation: void buttonSetup(Button button) { //Remove the existing events button.onClick.RemoveAllListeners(); //Add your new event using lambda notation button.onClick.AddListener (handleButton); } void ...


11

Here's a strategy for making arbitrarily bent UI: we'll render our UI into a texture (in realtime, not as a baking step), and then map that texture onto whatever mesh we want. Here's how I made this spherical example: Create a RenderTexture to store the UI. This needs to be quite high-res to get text looking crisp. I used 4096x2048 because I intend to map ...


10

You can do several things: -Make your GUI resolution indepentent, scale and position everything based on relative screen positions, this is often a lot of work. -Render your GUI to render target A of a fixed resolution (720P is often chosen), render your game to the screen, get the texture from render target A and render it upscaled/downscaled over the ...


10

The Navigation property of buttons is set to Automatic by default, allowing you to navigate through buttons using arrow keys. If you disable this by changing the Navigation property to None, buttons will not stay highlighted.


9

Magic and stuff. Orbs, staffs, scepters and green/purples came to my mind. Here's Some of it: A basic orb : Some Zelda style rupee (You could modify it to a suitable color) Basic staffs and scepters : Some potion : And also green and purple fire.


9

I think what you are looking for is something like following: GameObject CreateText(Transform canvas_transform, float x, float y, string text_to_print, int font_size, Color text_color) { GameObject UItextGO = new GameObject("Text2"); UItextGO.transform.SetParent(canvas_transform); RectTransform trans = UItextGO.AddComponent<RectTransform>(...


9

This is not technically an answer to your question, but is a better work around in my opinion. You can pass the dimensions of the boxes and the radius of the corners to the fragment shaders and round the corners that way. Basically, you take the current texture coordinates, multiply each coordinate of it by the dimensions of the window to get the ...


8

Back in January, 2011, I looked at five GUI toolkits for pygame, and tried to get all of them working with Python 3. The five were: Albow, GooeyPy, PGU, pqGUI, and sgc. I didn't succeed with GooeyPy, but I did get the other four to work with Python 3. (I wanted to also try poutine, by Shandy Brown, but I couldn't find it, and I entirely overlooked Ocemp.) ...


8

A while ago IMGUIs also caught my interest, as a test I wrote a couple of tutorials to familiarize myself with the techniques (start here if you're interested, but it's not much more than C#/XNA + the original 'tutorial' here). I really liked IMGUIs for a short while because the info they display is always up-to-date and correct (since there is no state you ...


8

I worked a lot with Unity3D GUI system, which works just as you described. And I must say, I hate it with a passion. "Immediate" approach works really good in some cases. First, when you only need a couple of buttons and labels - think shooter HUD, for example. Creating them with "retained" approach is not very hard, but its super-easy with UnityGUI. Second ...


8

If that is your first project, use Unity. It is easy to learn and will get your project done much faster. Compared to Unity, XNA is little more than a managed wrapper for DirectX. With XNA you have to do everything yourself, what Unity already implements seamlessly, there are of course libraries for almost everything specifically targeting XNA, but ...


8

The item you're talking about would be referred to as a progress bar: In this case, the progress bar is animated to fill up over a small amount of time. When completely full, the progress bar matches the highest score for that category. So, where 4975 is equal to 100% of the bar being full, 2000 is 2000/4975 = .40 or 40% full, as you can see in your ...


8

You can do this with the code below: title.color = new Color(254.0f/255.0f, 152.0f/255.0f, 203.0f/255.0f);


7

I am going to defend IMGUI here because some of the problems that were listed previously can be solved if you are willing to write the code for it. Additionally if you do write the code for it you then have a robust library that is re-usable and only very rarely requires modification. loading GUI from schema perhaps at first it seems that artists do not ...


Only top voted, non community-wiki answers of a minimum length are eligible