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 gdennis · Dec 07, 2014 at 10:59 PM · guiwidthguilabel

GUILabel wider than Rect width

My problem can be best shown by this picture: problem (alt link)

I obviously don't want the text to appear outside of the phone, next to the "from field". (note that the From: is put in the picture itself and the text next to it is the label text)

I have done this before and it perfectly works but for this one it does not work, the code is exact the same and looks like this:

     content.image = emailBig;
                         
     if (GUI.Button (new Rect ((Screen.width - wBig) / 2, (Screen.height - hBig) / 2, wBig, hBig), content)) {
     showBigEmail = false;
     Destroy(GameObject.Find("EmailOverlay(Clone)"));
     StoryFlowController.walkfile.enabled = true;
   }
     GUIStyle st = new GUIStyle();
     st.fontSize = 16;
     st.normal.textColor = Color.gray;
     //FROM label
     GUI.Label(new Rect(((Screen.width - wBig) / 2) + 110, ((Screen.height - hBig) / 2) + 240, 5, 50), "TTTTTTTTTTTT TTTTTTTTTT TTTTTTTTTTTTTTTTTTTTTTTTTTTTTaaaaTTTTTTTT", st);
                 


I intentionally use as width 5 and height 50 so the text should definitely not appear this long. Does anyone see what the problem is?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by hav_ngs_ru · Dec 08, 2014 at 05:09 PM

http://docs.unity3d.com/ScriptReference/GUIStyle-clipping.html

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 gdennis · Dec 08, 2014 at 07:28 PM 0
Share

Hello, thank you for your answer. I think it is somewhat in the right direction. However after applying

 sB.clipping =  TextClipping.Clip;

 

to sB (the GUIStyle) I get the following result: http://imgur.com/ZwoSuvb

The sentence gets cut off while I want it to appear obviously in the 'balloon'.

$$anonymous$$y code looks as follows (for that line)

 GUI.Label(new Rect(((Screen.width - wBig) / 2) + 170, ((Screen.height - hBig) / 2) + 160, 60, 150), message, sB);
avatar image Bunny83 · Dec 08, 2014 at 08:30 PM 0
Share

@gdennis: Well, you have specified a width of 60 pixels and that looks like 60 pixels... (just checked in mspaint, yes exactly 60 pixels ^^)

btw: You have a strange way to calculate your coordinates. Such a system will fail on different solutions. You mix fix pixel-offsets with size dependent elements. You might want to use some Groups to make the positioning simpler

avatar image gdennis · Dec 08, 2014 at 09:14 PM 0
Share

@Bunny83 Thank you for the groups tip, I will definitely look into that.

I do realize that I set the width to 60 pixels, but I also set the height to 150 pixels and I was hoping that would cause the text to enter and continue below it. However I think i missunderstood the use of it; Thank you for the help nontheless

avatar image Bunny83 · Dec 08, 2014 at 09:18 PM 0
Share

@gdennis: Uhm you didn't set wordwrap to true. I think you're rushing your project a bit too fast. Read the documentation carefully, try to understand the concept and keep your eyes open for useful things ;)

It's also more common to create a GUISkin asset and use that for your styles. That allows you to view all settings in the inspector and you can event change them while in playmode.

Also keep in $$anonymous$$d that the latest version of Unity has a new GUI system which is more WYSIWYG like and has better performance especially on mobile.

avatar image gdennis · Dec 08, 2014 at 10:51 PM 0
Share

Thank you @Bunny83! I may indeed be rushing this a bit, but since it's a school related project, they want to see results every week. I guess if the main functionality is working, at the end turning the coordinates I have now in Groups shouldn't be that much of a hassle I hope.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Need help with GUI label not displaying variable 1 Answer

full screen wide GUI.Box 3 Answers

Shrink GUI 1 Answer

GUI Label Score Overlapping - Javascript 1 Answer

getting gui error you can only call functions from inside OnGui. 1 Answer


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