I want to use a Textfield to let user enter some text.
But for some reason even in a multiline textfield the user can type as long as he want in the same line.
Also when text reaches the end of the box it starts to increase the textfield box itself and pushed all other ui elements away. Not to say enabling wrapping doesn’t wrap anything.
How can I limit the line length in a Textfield so it wraps and doesn’t increase the ui box?
How can I make the ui box keep the width and height of it’s parend visual element and not break out of it?
I just wonder why all these default ui elements which are in the ui toolbox are completely unusable.
Even basic settings are mostly missing.
Doing same things in html is a 1 minute thing for me. Here in unity I’m trying around since days to make the ui fit and work as it should. I’m really close to give Unity up.
@DCK2022 - you need to set the “Horizontal Overflow” property to “Wrap” and “Vertical Overflow” property to “Truncate” in the Text component. Additionally, you should set the “Content Size Fitter” component to constrain the width and height of the Textfield box.
Select your Textfield object in the scene.
In the Inspector, find the Text component and set the following properties:
To prevent the Textfield box from expanding its width and height, add a “Content Size Fitter” component to the Textfield object:
Right-click on the Textfield object and select “UI” > “ContentSizeFitter”
In the ContentSizeFitter component, set the “Horizontal Fit” and “Vertical Fit” properties to “Preferred Size”
Now, your Textfield should wrap text appropriately and not expand beyond its parent element’s dimensions.
let me know if this got you closer to an answer
Thanks for the feedback. Maybe I’m still not deep enough into unity. But I don’t understand.
How can I select my Textfield in the scene? I’m in the UI Builder.
I can select my Textfield there. But your properties doesn’t exist in the inspector.
There are some unity stylesheets, but they are all locked and not editable.
I can create a new style class within the Textfield and add it to the .uss file but it has just the same properties like the standard Textfield object. It’s also not editable so I can not add any additional properties.
I don’t understand what is the sense behind this style if they are not editable.
Can someone recommend a tutorial for restyling? I found some but they are not explaining how to do it in the UI Builder.