Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Pysassin · Jan 22, 2013 at 10:30 PM · guibuttonguilayout

GUI Button Text in upper left?

I am working on my HUD and have a "spellbar" type setup similar to MMOs and was curious how I would go about getting the text of the button (in my case just the number on the keypad that corresponds to that button) in the upper left corner of said button, as well as the texture underneath it. Just starting out with GUI programming so not sure what all you can do with it.

Comment
Add comment · Show 5
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 Punkjim420 · Jan 22, 2013 at 11:03 PM 0
Share

If you need a little more help, or want more info on GUI, go here: http://docs.unity3d.com/Documentation/ScriptReference/GUI.html

avatar image Loius · Jan 22, 2013 at 11:16 PM 0
Share

I rarely see an answer posted as a comment :p

avatar image Punkjim420 · Jan 22, 2013 at 11:25 PM 0
Share

should it not be a comment?

avatar image Pysassin · Jan 22, 2013 at 11:29 PM 0
Share

Punkjim at the very bottom you just type the answer down there no need to hit add comment. That way people can give you credit for answering the question. Gives your profile $$anonymous$$arma.

As for your answer given I will have to give it a shot. I know how to do the mouse click OR input thing just needed the label information thanks.

avatar image Punkjim420 · Jan 22, 2013 at 11:33 PM 0
Share

Alright, ill move it to an answer, i had assumed you were the one to decide if it were an answer or not. :P

Your welcome.

2 Replies

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

Answer by Punkjim420 · Jan 22, 2013 at 10:59 PM

There are a few ways to do that. One way you could do it would be to place a texture on screen for each "button" then place labels on top of each texture. Now if you want them clickable you would check mouse position and if you click the mouse when its in your boxes(buttons) position then it should call the "activating the button" function. Then if you want corresponding keys to run that function you just create an if statement saying:

if(Input.GetKeyDown(KeyCode.1)){ activating the button function here(); }

for placing the texture youd do something like this in your OnGUI function:

GUI.DrawTexture(Rect(10,10,60,60), aTexture);

and for a Label: GUI.Label(Rect(10,10,60,60), "1");

for the texture script to work you have to have a variable thats "aTexture" in name, and type Texture2D so you can assign the image you want in the inspector. now you just need to look around a bit for a method to find mouse position to make the button "clickable" and you might want to change texture image if the mouse does click it, so it looks as if its being clicked.

Hope this is at least somewhat helpful... good luck.

Comment
Add comment · 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
0

Answer by Bunny83 · Jan 22, 2013 at 11:51 PM

The short answer is GUIStyle.alignment

Comment
Add comment · Show 2 · 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 Pysassin · Jan 23, 2013 at 12:15 AM 0
Share

I'm not familiar with GUI Styles how do I use that to put it in the upper left? The script reference doesn't refer to how to change it unless I'm to noob to notice it.

avatar image AlucardJay · Jan 23, 2013 at 06:28 AM 1
Share

http://www.burgzergarcade.com/tutorials/game-engines/unity3d/026-unity3d-tutorial-guistyle-guiskin

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.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GUILayout Window Help 1 Answer

GUI Repeat Button problem 1 Answer

How do I fix my GUILayout.Button 2 Answers

How to put a GUILayout button BESIDE another one instead of below? 1 Answer

Unselect GUI Button 0 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