Hi,
I’m hoping that an explanation of how to do this will illuminate solutions to similar problems as well. If I create a plain EditorWindow and add an EnumField to the root visual element, its width will fill the entire screen regardless of the length of the values of the EnumField.
I would like the width of the field control to be auto-sized to fit the field values–even if it’s always set as the maximum width of any of the values.
How would I do this?
Hi,
This is the default behavior of flexbox. The root VisualElement flex-direction is column and by default its children will stretch on the cross-axis (horizontal) to fill all the space.
To change this you can use “align-self: flex-start” on the EnumField or “align-items: flex-start” on the EnumField parent which is the root VisualElement in this case.
See this page for more information about the layout : Unity - Manual: Position element with the layout engine