Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Content Size Fitter fails to drive size...but works if game view is resized?

Discussion in 'UGUI & TextMesh Pro' started by futurecrayon, Jan 16, 2015.

  1. futurecrayon

    futurecrayon

    Joined:
    May 7, 2014
    Posts:
    14
    I have some UI elements whose sizes are driven by Content Size Fitters. These objects are hidden (disabled) within the scene but revealed (enabled) by script when I start the game. (The following bug does not occur if the objects are enabled within the scene before I start the game.)

    These UI elements appear to be invisible, even though they are shown as enabled within the hierarchy and inspector. The issue seems to be that the Content Size Fitter is not driving their sizes (the "Some values driven by Content Size Fitter" label is missing from the Rect Transform component in the inspector), so their widths and heights are 0 (hence, they are "invisible").

    However, I can "force" the Content Size Fitters to drive their sizes by doing one (or some combination) of the following while the game is running:
    • changing the aspect ratio of the game view
    • minimizing/maximizing the game view
    • pausing/unpausing the game
    I don't know why these actions are causing the Content Size Fitters to take effect, but this seems like a bug to me. Anyone else experienced this? I first encountered in 4.6.0 b3 and it seems to still be in all the versions since.
     
  2. admin_8C

    admin_8C

    Joined:
    Jan 25, 2017
    Posts:
    8
    Exactly same here
     
  3. Jesper-Nielsen

    Jesper-Nielsen

    Joined:
    Nov 14, 2013
    Posts:
    95
    LayoutRebuilder.ForceRebuildLayoutImmediate() might work?
     
  4. Izzy2000

    Izzy2000

    Joined:
    Dec 18, 2013
    Posts:
    49
    unrelated... remembering the issue.

    yea... this was an interesting feature to implement in kissUI. :/



    go it to work by telling all children which parents required content resizing.
    works great on multiple ancestors as needed. :]
     
  5. admin_8C

    admin_8C

    Joined:
    Jan 25, 2017
    Posts:
    8
    I m sorry but copy paste this line doesnt explain so much and doesnt works...

    I fixed it with an ienumerator which change something on canvas after a certain delay... Like that it forces the resize. That is a way........