Set different padding for each child of a Vertical Layout Group

Hello,

I have a Vertical Layout Group with “child force expand - width” set to false.
As children of the Vertical Layout Group, I have several GameObjects with a Text component on each. For example, a Title, a Subtitle and a normal text. They have different font size, style and colors.

When I set the left padding of the Vertical Layout Group, all the text children are offset by this value (which is normal).

However, I want to define a different padding for each Text. Example : I want my title with a padding of 20 pixels, and my subtitle with a padding of 50 pixels.

How can I do that ?

Please take a look at the screenshot :

On the left, what I get, and on the right, what I want (I use space chars before the text but I want to do it without any space chars).

1 Like

would you consider using a separate Text object for the indented sections?

Hi,

Yes it is already the case, maybe I was unclear.
Here the hierarchy :
2878662--211198--screen_problem_hierarchy.png

I have 3 Text components :

  • TextTitle is “Ingredients”,
  • TextSubtitle is “Mon sous-titre”
  • TextNormal is the other text.

And PanelContentRecette has a Vertical Layout Group.

You can wrap each text with Panel and change text position relative to this panels

Oh yes I didn’t think about it, thank you very much !

I really want it too, I can’t change to more elements, I just want to do it just in Text,

because I continue working on very old project and I can’t change it too much.