Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question uGUI: content size fitter update bug

Discussion in 'UGUI & TextMesh Pro' started by Sengaya, Aug 26, 2022.

  1. Sengaya

    Sengaya

    Joined:
    Nov 21, 2018
    Posts:
    9
    Is there any chance you will fix the buggy update behaviour of the content size fitter (without having to use "ForceRebuildLayoutImmediate", "RepaintAll" or "ForceUpdateCanvas" etc.)?

    Especially when used with layout groups or nested into another game object with content size fitter, the necessary size calculations are not performed correctly (not in the right order i guess) which leads to the ui being not built up correctly or if so, only after a few "disable/enable switches" of the canvas.

    Would be a real life saver to have this, because it is a pain to have to write a script for every single time i use a content size fitter.

    Thanks guys!
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Is there a bug report for this?
     
  3. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    247
    Are you using the content size fitter on objects whose parents have a layout group? If that's the case, you should avoid that, it won't work correctly in several situations (by design). Anyway, it will help the devs and everybody if you give an example of a setup that fails (and filling a bug report as jRocket commented if you didn't already).

    I rarely use content size fitters, but when I've used them the issues I had were caused by an improper setup from my part, and I could resolve them by fixing it, though sometimes it takes a bit to understand what the issue is.
     
  4. Sengaya

    Sengaya

    Joined:
    Nov 21, 2018
    Posts:
    9
    @Trisibo Yes it often occured with layout groups, but not only and i can't think of any other way of achieving something like a list of mission objectives with different text lengths in headline and copy for example. If there is a better way i would appreciate a hint :)

    @jRocket Not sure if this is an actual bug report, but i guess it is: https://issuetracker.unity3d.com/is...ze-when-childs-contentsizefitter-changes-size

    Also the issue is well known for years and being discussed in many forums, so i assumed the devs might be aware of it.

    Unfortunately i don't have any example to show right now, but you can see the issue in a post on reddit from 5 years ago: https://www.reddit.com/r/Unity3D/comments/77j8p9/content_size_fitter_not_updating_automatically/
    direct link to example from that post:
     
  5. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    247
    I see. As I just mentioned in other thread, I try to avoid content size fitters and just use layout groups and layout elements for most setups, definitely for the one you show. It took a bit to "click" in my head, and still sometimes can take some trial-and-error for some setups, but so far they have been rock-solid for me.
     
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    What you are asking for is more a feature request that will require a large rewrite of the layout system. Currently its not something that would be a quick fix based upon the architecture of layout. With the current focus on UI Toolkit features like this will currently not make the list for dev priority.

    Its not a great answer i know and not the one you are likely hoping for. All that being said ContentSizeFitter has come up a lot already today in a short period of time so without any sort of promises its now higher on my radar.
     
  7. Sengaya

    Sengaya

    Joined:
    Nov 21, 2018
    Posts:
    9
    I'm not sure if it is a feature request, since many other people expect the content size fitter to work that way and haven't come around a solid way to do it differently, but i can understand that this is not very high on your priority list.

    Could you probably recommend a resource that explains a practicable workaround for this?
     
    AldeRoberge likes this.