Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 wechat_os_Qy01-PnYRvujfNwxke037baX0 · Apr 12, 2021 at 11:55 AM · uilayout

LayoutRebuilder.ForceRebuildLayoutImmediate doesn't work correctly in nested layout.,LayoutRebuilder does not work in Nested Complex Layout

source code of UGUI, it seems like it can fit in nested layout. alt text

However,it doesn't work when I call the function "LayoutRebuilder.ForceRebuildLayoutImmediate" once at the root node. I have to call this function multiple times like that when I met nested layout. (from bottom to top, child to parent) alt text Does anyone know why the source code doesn't work well as I expected and what I can do to deal with the problem properly.

img0412.png (102.5 kB)
qq截图20210412174341.png (35.2 kB)
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 unity_VvCODKknmBJQGw · Jul 11, 2021 at 07:42 AM

Hey mate, unfortunately, your snippets seem like very bad practice

I haven't figured out how to solve this myself, but it just doesn't seem fit to force so many layout resets. What I have found, though, is that usually, it has to do with the layout in your hierarchy. For example, a text placeholder that will adjust its size, that is inside another placeholder that will adjust its size too. In this case, I just had to have two layout resets, as the first will affect the inner placeholder (the one that holds the text), whilst the second will affect the second (the one that holds the placeholder)

I would love to see some answer to this issue as well :)

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 unity_VvCODKknmBJQGw · Jul 11, 2021 at 07:46 AM 0
Share

I actually came across the following solution - it seems to work perfectly. Source: https://forum.unity.com/threads/force-immediate-layout-update.372630/

[QUOTE="gresolio, post: 5604151, member: 519501"]

I want to slightly expand the Sun-Pengfei's answer. After long adventures and frustrations with UGUI, I can say with confidence that reading the source code helps better than official documentation. There are many "not a Bug, but rather a feature by design" things, won't be fixed in current HorizontalOrVerticalLayoutGroup ;) To avoid using ForceRebuildLayoutImmediate or/and some manual update workarounds, the following approach works well:

Both "child controls size" checkboxes must be enabled and "child force expand" disabled for all ILayoutController (Horizontal, Vertical, also for nested ones), then to control the dimension of the objects you simply use the LayoutElement component ($$anonymous$$, pref, flex sizes). As a result, any dynamic content is correctly aligned, regardless of the activation/deactivation/addition/removal of neighbors.

Note 1: There is no need for ContentSizeFitter component for GameObjects, that are first level children of any LayoutGroup. The main thing is to correctly set the checkboxes, as described above. However ContentSizeFitter may be useful for top level container, or children of children that are not directly controlled by any LayoutGroup.

Note 2: Minimize LayoutGroup nesting when possible. Layout rebuild is very expensive. More info on topic: Unite Europe 2017 - Squeezing Unity: Tips for raising performance. [/QUOTE]

avatar image sellverful unity_VvCODKknmBJQGw · Dec 10, 2021 at 03:31 PM 0
Share

Wow, this is actually really nice. In horizontal layout with images and flexible text it works perfectly. I totally need to read more about this. Thanks, man

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

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

How to scale UI elements smaller so they can fit onto panel when increased in number. 1 Answer

Layout group items are not fitting well 0 Answers

Input field in layout 0 Answers

Grid layout group stretching text 1 Answer

Layout Poprerties- can't get 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