2
\$\begingroup\$

I wanted to display an HUD, similar to the strategic games' one (like in DotA 2, Warcraft III, Starcraft II or Age of Empires). I didn't really know how to do it, so I managed to create a Texture Object and placed it in front of the scene. The image attached is the HUD itself, with some transparent "holes" in which I placed the cameras. I don't know if this description explains well what I'm trying to say, so I made this screenshot:

Free Aspect - How it's meant to be

The HUD is just a png image with a greater z-index. The image has three "holes": one for the gameboard, one for the dice, and one for the spells you can see on the right. The holes are filled with the cameras, so we can see the objects beyond the transparency. Everything looks quite nice.

But if I change aspect ratio (which was Free Aspect), my layout gets completely screwed up.

Aspect Ratio Changed - Layout gets screwed up

Notice that the HUD borders are not fully displayed; the spells on the right are misplaced, and so are the dice.

I managed to get the free aspect resolution, it is 1440x720, a perfect 2:1. But, even if I change my resolution to 800x400, things are not getting better.

Even with 2:1, things do not get any better

I've read something about pillarboxing and letterboxing, but I'm not sure that those techniques will help me with this issue. Is there something I can do to resize my objects and my cameras dynamically to fit the screen for every resolution like in the first screenshot?

Of course, if you have any other solutions for the HUD, I'll be glad to learn!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

GUI system is THE annoying aspect of Unity3D. What missing is anchoring to camera's bound (thus anchoring to different screen size automatically) or automatic stretching according to some kind of 'panel' Here are some possible alternatives :

  1. Use GUITexture/GUIText game object since the position property of that object is special : it uses 0~1 scale mapped to current screen position. But you can't do things like right-align to the edge of your screen.
  2. Use third party plugins like NGUI or DFGUI. Both is one of the most grossing item on the asset store and you can also have older version (2.7.0 I think) of NGUI for free here. But some learning will be required.
  3. Wait for Unity 4.6 where the promised Unity GUI will comes to light. (Also this. lol)
\$\endgroup\$
2
  • \$\begingroup\$ I'm not afraid of learning (it's what we all do everyday, after all! :D), and I believe your 2nd solution would be a real painsaver. Is there any documentation? \$\endgroup\$
    – Vereos
    May 20, 2014 at 12:07
  • \$\begingroup\$ Yes it is : tasharen.com/?page_id=197 \$\endgroup\$
    – 5argon
    May 21, 2014 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .