To my surprise … UIToolkit’s defaults for Label don’t wrap text - if there’s not enough room horizontally (even if there’s infinite space vertically), they simply truncate.
The 2018.x build of UIToolkit (UIElements) had a property in IStyle that let you set the wordwrap behaviour, but this is now vanished, and searching the docs gives zero hits (Google can only find the deleted item, not any kind of replacement).
How do we change UIToolkit Labels so they wrap correctly?
CSS has flex-wrap, which appears in UIToolkit as “Wrap” - but that’s completely separate, and cannot apply to text (it applies to elements within a flex scope).
CSS has word-wrap, which is what Unity has deleted in 2019.
I can’t find anything that Unity HASN’T deleted which fits this
var section = rootVisualElement.Q<VisualElement>( "MyDataArea" );
descField = new Label("Some really long text is goinna go here ads fslksdf ldsfj kldsf s" ) { style = { whiteSpace = WhiteSpace.Normal } };
section.add( descField1 );
Out of interest … do you know if there is a particular reason why this isn’t the default?
I think it was just a judgement call that in most game UI, the Labels are not large paragraphs and instead serve as actual labels on fields, buttons, title bars, etc. Such use cases typically actively do not want text to wrap at will (think Buttons becoming taller randomly). Using Labels for larger text blocks is a less common use by comparison.
The buttons I designed were large enough for word wrap but I could not find the style for it. I think they need to relabel the descriptor for the style class in the text item in the UI Builder inspector as well.