- Home /
Layout group children adjust to content
Hi Unity Community
I am trying to make two children (a UI Input Field and UI Text) of a Vertical Layout Group adjust vertically to their text component input content.
The docs suggest that you need to add a Layout Element to the child you want to expand (which I have done), disable the Child Force Expand from parent Layout Groups (which I have done) and set their Child Alignment (which I have also done (Upper Left)).
While the Input Field now expands large enough to account for larger amounts of text input, it is not responsive to the amount of text entered into it. The Text UI object does’t expand at all to account for the text input length (this is derived from the Input Field string return) and the Content Size Fitter conflicts with the parent Layout Groups (I'm pretty sure I followed the docs right?).
Can someone please explain to me where I am going wrong; it seems so simple yet I can’t seem to get this functioning properly.
Many thanks in advance,
Ryan
GUI (first highlighted element is the Text component - notice it hasn't adjusted to the appropriate height of the Input field content - second highlighted section)
UI Text Editor Settings !
Parent Layout Groups, Input Field and Text Editor Settings
Answer by RyanAchtenSoma · Sep 08, 2015 at 01:31 AM
I'm not actually sure if this is even feasible with the default InputField, as described in this post here: 'because of the logic in the script to position the Caret and overflow text handling. The Layout is not updated to take account of the text content. The control is actively working against you in this case.'
Seeing as this may not be feasible (without detracting from the purpose of this question), I have temporarily created text and input fields at a set size.
However if anyone has a work around to this issue using the built in UI system I would be very interested to hear your thoughts.