- Home /
Automatically resize scrollview based on vertical text length (Solved)
Goal: Have a scrollable viewport to display different unknown text in the form of strings, where text is constantly added to the end of it as new entries.
Method used so far: Unity UI scroll view object, with text panel as a child.
Issue: When text is added to the existing text child, the object holding it does not expand with the text. The scroll bar only scrolls for the objects height and does not consider the texts actual height
Probable solution: Something that checks how much physical space the text takes up, and resizes the game object to that size, or something around there.
Additional Info: Ironically, the input field where I'm typing my question is almost exactly what I'm shooting for. As you write more text, the scroll bar gets smaller and smaller and lets you scroll over larger areas.
EXAMPLE TEXT: (It's basically like an ingame console)
You: use item
Invalid command
You: use item2
Success
Basically, there's a panel with a text element. When the text element becomes longer than the panel, make the panel match it's height.
Answer by oStaiko · Oct 24, 2016 at 07:33 PM
Okay. There's a game component called "Content Size Filter" that does exactly this. Just add that as a child to the panel and it does all the work for you.
Answer by piginhat · Jan 13, 2018 at 10:31 PM
can you expand please (pardon the pun!)
I have tried adding a content size fitter to, ViewPort (but gets disabled due to layout group of parent), Content and text game object within Content.
Nothing makes the content container size dynamically to the text child within?
Your answer
Follow this Question
Related Questions
How to measure the width of a string? 0 Answers
How to use special symbols 1 Answer
,InputField backspace returns already send text 0 Answers
What's your equivalent of old GUIStyle ? 0 Answers