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 Limnage · Sep 13, 2013 at 11:35 PM · guitextbox

Providing a start location for GUILayout.beginHorizontal ?

Here's the code I have right now:

         GUILayout.BeginVertical(textBoxStyle);
         GUILayout.BeginHorizontal();

         GUILayout.Label("Here's some test text.");
 
         GUILayout.EndHorizontal();
         GUILayout.EndVertical ();

This gives me the desired behavior in terms of vertical and horizontal expansion: the text box around the label is automatically sized to contain the label's text. The problem is that it's at the upper left part of the screen.

If I add a GUILayout.BeginArea() and EndArea() to wrap that code, then I can place it wherever I want, but for some reason the desired autosize behavior goes away for the width. The height is correctly autosized, but the width of the text box goes to the full width of the Area, even if the text is shorter than that. I tried putting a ExpandWidth(false) in the BeginVertical, BeginHorizontal, and the Label, but this changed nothing. Why is this undesired behavior happening only for the width of the text box, but not for the height, and how can I fix it?

Comment
Add comment · Show 7
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 Jamora · Sep 13, 2013 at 11:56 PM 0
Share

What happens if you use your style in the Label i.e. GUILayout.BeginLabel("text",textBoxStyle); ins$$anonymous$$d of the BeginVertical?

avatar image whydoidoit · Sep 14, 2013 at 05:37 AM 0
Share

How about sticking a BeginHorizontal around the whole lot to tell it that it needs to use the screen width?

avatar image Benproductions1 · Sep 14, 2013 at 12:20 PM 0
Share

use GUILayout.FlexibleSpace. Sometimes (and irregularly) the automatic spacer for GUILayout is crappy and doesn't do things like it should. Can't wait till the new UI system comes out XD

avatar image Limnage · Sep 14, 2013 at 10:57 PM 0
Share

The textBoxStyle is just for the textbox background. I'm using BeginHorizontal and BeginVertical because I'm hoping to concatenate multiple labels together, i.e. http://answers.unity3d.com/questions/535695/best-method-for-multiple-styles-within-textbox.html .

I tried putting another BeginHorizontal around the whole thing, but that didn't help.

GUILayout.FlexibleSpace just adds space, right? I need to do the opposite. Right now it's expanding the text box to be bigger than it needs to be. I'm hoping to automatically size the width just like the height is being automatically sized.

avatar image Jamora · Sep 14, 2013 at 11:20 PM 0
Share

If you're using a GUISkin (I assume you are because you have several styles), there's an option in each style for "Stretch Width". Have you tried turning that off?

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

18 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Deselecting Textarea when button pressed 1 Answer

How can I clear a textbox and repeat the text with my effect? 0 Answers

How to get a pop-up window floating next to a gameobject? 1 Answer

Simple text in a box - on player collision 2 Answers

How do you get a caret to show in GUILayout.TextField ??? 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