- Home /
HUD (Heads Up Display) creation
How would one go about creating a HUD?
Not exactly like this but similar. Basically, The HUD will show the map (both galaxy map and star system map)(bottom left), a chat system (both private chat, race chat, global chat)(bottom right), and some player info (Shields, Health, currency, rank, etc)(Top right).
Answer by TowerOfBricks · Nov 23, 2009 at 07:37 PM
All that is possible with the GUI system. I think there is a chat example in the networking example project ( http://unity3d.com/support/resources/example-projects/ ). Search on the forum forum for tips on how to create a minimap. Player info can be added however you want, just create some labels and add the info. For the style I suggests that you take a look at GUISkins or GUIStyles (see the docs). The rest is just textures and icons.
For all those markers on the screen indicating other ships and that sort of stuff, you can take a look at Camera.WorldToScreenPoint (I think that is what the function is named anyway).
Just to mention that this sort of GUI is quite complex and will take a long time to code up.
Hope it gives you some help.
Yeah, I am building this for the Win/$$anonymous$$ac. Actually a browser-based setup. I started building the GUI. But I guess I am confused on how to do certain aspects of the setup. For example: look at this image: http://www.blogcdn.com/www.massively.com/media/2007/12/os1203.jpg Just for the purpose of having custom graphics, not exactly what I want it too look like, but the idea of it. I don't know how to do this... SpiritWebb 0 secs ago
Answer by Jaap Kreijkamp · Nov 24, 2009 at 06:49 AM
If performance is key you can best use some sort of 'sprite manager' and draw the whole GUI in one draw-call. You need to place all GUI elements on one texture for this. You can do the same for font rendering. In my current projects I use a simple sprite manager and simple font manager I made on the go but on the scripts wiki there's a sprite manager that should do the trick and is better documented (and probably better designed, mine is mainly about speed and simplicity for my specific case).
If you want it I can supply you my code but haven't got time to really give support on it and as I said earlier it's quite rough and badly documented, especially the font thing. The font thing is also more complex because you need to make fonts for it and currently I only support the font tool created by angelcode (free but you have to google it to find it). Basically it does about the same thing as TextMesh, so for text that's probably a good option to look into.
EDIT: erm, as I came to UnityAnswers from the iphone developers forum I automatically assumed that the question was about making an iphone game where draw-calls are bad bad bad, if this is for Win/Mac platform, don't bother and use normal GUI code :-)
Yeah, I am building this for the Win/$$anonymous$$ac. Actually a browser-based setup.
I started building the GUI. But I guess I am confused on how to do certain aspects of the setup.
For example: look at this image: http://www.blogcdn.com/www.massively.com/media/2007/12/os1203.jpg
Just for the purpose of having custom graphics, not exactly what I want it too look like, but the idea of it. I don't know how to do this...
Custom graphics can be added in the GUISkin asset, create a GUISkin, add a custom style and then use your script to render it ( GUI.skin = mySkin ). You should also have a look at GUILayout.BeginArea and GUI.BeginGroup, with them, you can make groups of objects which are much easier to place on the screen opposed to placing all of them by hand. Also, if you want to have GUI which always stick to the middle of the screen for example, take a look at Screen.width and Screen.height.
I guess I am confused on the custom style. I tried adjusting different aspects and it wouldn't work. I got it too show on the screen and able to move it around on the screen, but say I want to create a box (GUI.Box(Rect (10,10,150,20)); But if I want to use a cusomt skin, how would I apply the above without using the default, and want a background color of the box to be a dark blue?
Read a bit in the scripting reference about Gui.Box, most often you define a variable in your script named for example gskin which holds a GUISkin object, then in the OnGUI function you define GUI.skin = gskin; After that you render your GUI, to add a custom style you most often just add another string which holds the name of your custom style: GUI.Box (new Rect (10,10,10,10),"$$anonymous$$y Box","$$anonymous$$yStyle");
The docs does also have a great tutorial about GUI: http://unity3d.com/support/documentation/$$anonymous$$anual/Game%20Interface%20Elements.html