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
1
Question by entity476 · Mar 05, 2015 at 11:42 AM · uiyieldlayout

4.6 UI.System: Triggering Layout Rebuild help

Hello community!

Copied from the manual's documentation on recalculating the Auto Layout of the UI system, by using the LayoutRebuilder.MarkLayoutForRebuild (transform as RectTransform) function:

"The rebuild will not happen immediately, but at the end of the current frame, just before rendering happens."

From this instruction only, I assume that I have to wait for the next frame, so that the current modifications in the layout's properties will take effect and therefore to be possible to consider them in new calculations. With this assumption I have been using a yield instruction right after I have called the Rebuild function. Am I correct so far?

There is a visual side effect of using the yield coroutine, however. Given that the layout changes are applied within a number of frames by the end of each one the graphics are also calculated, the result is an animation effect of the changes. Although in my case it is not a bad contribution (rather the opposite), I was wondering on one hand, if I even approach the whole thing correctly and, on the other, what can be done if this animation effect is not desired. Is there even a way to move to the next frame, without having the graphics of the particular objects updated, until we want this to happen (in this case, after the layout changes have been applied)?

Thanks in advance for any help. Since the UI system is relatively new there are not many examples around (especially regarding run time GUI development) from which I can get ideas and solutions.

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

Answer by entity476 · Mar 17, 2015 at 07:27 PM

I am not sure, if I didn't make my problem clear or it is true I guess that not many exploration in the world of the new UI is done and even if this might be an issue of a more general nature, I will contribute my finding, even though I'm not sure, if it is totally correct.

So my main concern had been to remove the yield statement and still have the layout of the controls updated, before the end of the frame. I found out that by calling the Canvas.ForceUpdateCanvases() function instead, I get the desired result. I haven't done a lot of testing and I don't know if it's the most efficient solution or better yet if my whole approach is good, but I will rest with that for the time being.

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 ryo0ka · Aug 12, 2017 at 05:21 AM

Also check out UIBehaviour.OnRectTransformDimensionsChange() which invokes when its RectTransform's proportion changes during a layout. This sometimes works when Canvas.ForceUpdateCanvases() doesn't. Coroutine is the last resort.

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

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

21 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

Related Questions

Combining aspect ratio fitter with horizontal layout group 0 Answers

Layout error after crash has effected canvas scaling 1 Answer

How to Stretch objects in grid layout when screen size is changed 0 Answers

Scale Layout elements to fit screen 2 Answers

How do you automatically fit a child of a layout group to the parent without it adjusting to fit its own contents? 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