• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by SpiritWebb · Nov 23, 2009 at 05:39 PM · guiguilayout

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpiritWebb · Nov 24, 2009 at 02:47 PM 0
Share

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

avatar image
0
Wiki

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

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpiritWebb · Nov 24, 2009 at 02:47 PM 0
Share

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

avatar image TowerOfBricks · Nov 24, 2009 at 03:35 PM 3
Share

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.

avatar image SpiritWebb · Nov 24, 2009 at 04:56 PM 0
Share

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?

avatar image TowerOfBricks · Nov 25, 2009 at 09:56 PM 2
Share

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");

avatar image TowerOfBricks · Nov 25, 2009 at 09:59 PM 2
Share

The docs does also have a great tutorial about GUI: http://unity3d.com/support/documentation/$$anonymous$$anual/Game%20Interface%20Elements.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. 0 Answers

know GUILayout current screen position 2 Answers

"'UnityEngine.GUI.DoTextField' is inaccessible due to its protection level." 1 Answer

Having a GUILayout Window position immediately at screen center 5 Answers

Why can't I get my tooltip to show only when there is a tooltip set? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges