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 ...


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 ...


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 ...


17

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 ...


14

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

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.


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 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

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 ...


9

Its entirely possible. Here's a simple script showing how. using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; public class PopulateSprites : MonoBehaviour { public List<Sprite> Sprites = new List<Sprite>(); //List of Sprites added from the Editor to be created as GameObjects at runtime public ...


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

Alright my dude. Welcome to the hell that is layout groups. Here's a few things you'll need to know first: If nothing is sizing the object, the layout group will not work as you expect (in fact it appears the opposite). Things that size the object include LayoutElement and ContentSizeFitter. For whatever reason the default rect transform sizings make the ...


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

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

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 ...


7

Flexible & Accurate: Filters Use a texel filter either on the texture on the CPU side, or if you are using programmable pipeline OpenGL, directly in the fragment shader. The idea of a filter is simply that you run through a 2D loop to process every texel. If it is white, then you run through an inner 2D loop for each of its surrounding pixels in some ...


7

There are pros and cons to both, but the decision is ultimately yours. You'll have to decide based on the style of your game and the type of game. Static position: Always in the same place, predictable. This means the user will always know where the indicator will be and allows them to avoid covering it up on their own. Kind of boring and requires some kind ...


7

Usually, elements in graphical user interfaces are laid out in a hierachical fashion, e.g. all the elements are children of the window or another element. In most ui systems I've worked with so far, the parent element is responsible for layouting the children. But let us digress to event handling first: When a user clicks somewhere on the gui, the window ...


7

Let's call the content you want to scroll content and the viewable area of that content viewPort. Your scrollbars will be at the sides of the viewport. The first step is to create a mask such that only parts within content which intersect with viewPort are visible. I can't answer exactly how to do this because it depends on your language and technologies. ...


7

Here is a rather simple extension class that you can use. public static class GraphicExtensions { /// <summary> /// Fade methods forUI elements; /// </summary> /// <param name="g"></param> public static void FadeIn(this Graphic g) { g.GetComponent<CanvasRenderer>().SetAlpha(0f); g.CrossFadeAlpha(1f, ....


7

It is a bad idea insofar as it is nonsensical. There is nothing to "set up" that you have not already done, except for an ortho projection matrix (which you will have to do in any case). Portability is probably not a problem, although it should be. IHVs seem to be very reluctant to drop support for immediate mode for the foreseeable future (it seems to "...


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