- Home /
Vertical Layout Group Not Behaving Even Close to Correctly
I'm trying to make a chatbox by adding multiple text elements to a vertical layout group with a content size fitter. This was working fine with TextMeshPro while my canvas was at constant pixel size. However I needed to change my canvas to scale with screen size, and now the vertical layout group refuses to do what I say. Here are the settings for my layout group:
Here is what the scene looks like when I add a text element:
This is with no padding or spacing. It just decides that upper left means all the way to the right, off of the screen entirely. If only this was consistent, I could account for it, but I can not predict where it will decide "upper left" means. Any ideas anyone?
Something to note: I am adding the text elements dynamically via script and setting sibling position. If I do add elements statically the layout group works fine.
Answer by rodeowild · Feb 05, 2020 at 09:39 PM
If I go back to using text mesh pro this is the error I get: At least this is on the right, but for the life if me i can't get it to align correctly.
Edit: Ok so I figured out why the alignment was off on text mesh pro. It was the text mesh pro margins settings which somehow set left to something non-zero. setting to zero fixed the issue.
I wound up using text mesh pro and adding a ton of padding (290) but obviously not ideal. If anyone has any idea why this was happening please let me know.
Your answer
![](https://koobas.hobune.stream/wayback/20220612222817im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why doesn't childing a gameobject to GridLayoutGroup at runtime align it properly? 1 Answer
Display loaded UI Image in Container with native size 0 Answers
Content size fitter alignment issue 1 Answer
Tween animations when adding / removing from layout groups 0 Answers
Unity crashes when using ExecuteAlways on a UIBehaviour 0 Answers