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 Kaz_Yamof · Sep 29, 2014 at 09:16 PM · uilayoutstretching

uGUI Vertical Layout Group stretching objects

Hi, I'm creating a log console, and I have an gameObject called Content that is an container for text's messagens. When a message is added to Content, I'm calculating a new size to the panel based on count of messages * height of message RectTransform (I will use an scroll bar when an limit was reached). I set a verticalLayout on my Content obj to automatically align the messages, and works fine, because I'm recalculating the panel size to fill properly. If I don't recalculate, the VerticalLayout is stretching the Text components to fit over all Content size.

Is working fine to me as is, but I would like to know: there is any way to avoid the vertical layout stretching?

Thanks!

[EDIT] Using 4.6 GUI.

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
2
Best Answer

Answer by Kaz_Yamof · Dec 05, 2014 at 09:03 PM

I solved this problem using the Layout Group. This is my structure:

  • RootGameObj (VerticalLayoutGroup[ChildForceExpand.Height=false, ChildForceExpand.Width=true])

  • ..child1 (LayoutElement[PreferedHeight=true and set the original value to be kept)

  • ..child2 (same as above here)

  • ..childN (same as above here)

Doing this way the VerticalLayout organized my elements respecting the respective heights of each element.

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
2

Answer by dayone · Oct 23, 2014 at 03:42 PM

If you add a Layout Element to your object you can prevent stretching. Since 4.6 is still on beta there isn't any documentation for it but for me it works like this:

In order to avoid stretching I changed the Flexible Height to 0(Other values keeps stretching). After setting value to 0, changing the Preferred Height/Min Height will let you change the height.

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 Kaz_Yamof · Dec 05, 2014 at 08:48 PM 0
Share

Well, it kind of worked. Not as you said, but using this component.

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

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

Related Questions

I don't understand "Child Force Expand" on uGUI 2 Answers

How do I layout dynamically instantiated UGUI components? 1 Answer

Where's Canvas Scaler? 1 Answer

Increase height of panel w/ gridlayout when new objects added 1 Answer

Unity5 new UI render problem on Android 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