Search Unity

Nested Layout Groups & Content Size Fitter

Discussion in 'UGUI & TextMesh Pro' started by CuriousPatient, Jun 25, 2019.

  1. CuriousPatient

    CuriousPatient

    Joined:
    Aug 12, 2014
    Posts:
    9
    Hello everyone on this beautiful day, full of challenges :cool:



    I am looking for help with the following problem:

    In general, the problem is shown in the video below.

    I am working on generic interface where there are many automatically scaled elements.



    Previously, I used to created very similar things and everything works in the editor, but when I run the simulation, the entire interface resets and collapses. But, it's enough to just change something (during runtime), for example, move, turn it off, turn it on and then everything works. So far I've solved this with a reset script at the start of the simulation (or when the interface appears) that turns off and on one of the UI elements, but this is a bit unprofessional solution.

    Hence the question of how to properly build such interface? o_O



    I think it all boils down to this warning: "Parent has a type of layout group component. A child of layout group should not have a Content Size Fitter component, since it should be driven by the layout group."

    But in that case, how to create autoscaling interfaces (that looks exactly the same as the Unity Inspector)?



    Thanks for help!

     
    Gasimo likes this.
  2. AmazinJacks

    AmazinJacks

    Joined:
    Oct 22, 2019
    Posts:
    9
    I can't see your video, but from your description I'm battling the same thing.

    Layout Group and Content Size Fitters do not work the same in practice as they appear to work in the scene when doing layout.

    Also - sometimes if you check various width/height control boxes, and then uncheck them, the scene still appears as though they were checked. Whether or not that is the case, why it happens this way and how to work around that is still a mystery to me.
     
    Gasimo and unity_uCAh1YGgjxXPOw like this.