1

I have canvas with vertical layout and 2 elements within (in fact it's element with only recttransform on it, let's call it container). So these 2 containers take a half of the screen by height and stretched by width, ok. How can I place an text element in above container and snap it to the bottom of this container? I tried press bottom button in recttransform widget (also with shift and alt) and it seems it doesn't affect my transform at all

P.s. May be I can use some free plugin instead of default unity components of UI layout?

IC_
  • 1,624
  • 1
  • 23
  • 57

2 Answers2

2

There are different ways of placing your UI elements

  • Simply drag and drop it to the bottom where you want it
  • Use the anchor widget to set the anchoring to bottom with horizontal stretch and hold shift to also set pivot. Then set Pos Y to 0. Set Left and Right to 0.
  • Assuming you also want other elements in your containers, place a Vertical Layout Group on each container and make sure that your text element is the last child of the container in the hierarchy.

I would also advise you to seek out tutorials on Unity UI anchoring, positioning, scaling, and layout. You need a deeper understanding of how these things interact than you are likely to get from Stack Overflow. Otherwise you will suddenly find that your UI behaves in unexpected ways when rearranged or displayed on a different aspect ratio.

0

It's fairly easy with Unity UI system. You just need to get used to it. Here are simple steps to accomplish what you want:

  1. Create Text element as a child of that container.
  2. Select your newly created element and edit its RectTransform component values:
    2.1. Set both Y axis anchors (min and max) to 0.
    2.2. Set pivot value to 0 as well.
    2.3. Set Pos Y value to 0 as well.

Now your Text element is anchored at the bottom of the container and its position (and height) is measured from the bottom of the Text element itself.

tsvedas
  • 1,049
  • 7
  • 18