Search Unity

Feedback Editor Label + Control: Size and Growth

Discussion in 'UI Toolkit' started by Catsoft-Studios, Dec 22, 2021.

  1. Catsoft-Studios

    Catsoft-Studios

    Joined:
    Jan 15, 2011
    Posts:
    703
    I've been working with UIToolkit for quite a while now and I liked the fact that the Label on a control was of a fixed size (150px if I'm not mistaken), and the rest of the width was filled by the actual control.

    Screenshot 2021-12-22 at 19.08.09.png

    However, with the latest versions of Unity, this behavior has changed to something much more similar to IMGUI...

    And that would be a good thing if it wasn't because of the fact that the growth of the Label and the right side control is not dictated by USS, but by some post-processing script with values that emulate IMGUI:

    https://github.com/Unity-Technologi...ui/Core/Controls/InputField/BaseField.cs#L294

    Wouldn't it be much better if these were purely controlled by some .uss settings? It would also make our lives much easier to those who try to design editor controls that align well with Unity's native ones.

    I just tested using values of 0.45 and 0.55 to Label and right-side control's flex-grow and it looks great, without the need of using an event that recalculates the size every time the geometry changes.

    Edit: I hope this doesn't sound like I'm telling Unity how to do things. I'm just curious about the decision of driving the layout using plain C# when USS was specifically made to avoid that, and using a Label and Control flex-grow value of 0.45 and 0.55 respectively works just as great.
     
    Last edited: Dec 23, 2021