Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change direction of expanding vertical layout group unity3d?

When I`m adding new elements on vertical layout group and when there is no more place to them vertical layout group starting to expand downstairs. How to make them adding from the top of each other?

What do I want:

  • 4th element
  • 3th element
  • 2nd element
  • 1st element

First element is always downstairs, next elements are spawning at top of it.

Thanks.

like image 543
Konstantin Zhuk Avatar asked Apr 03 '17 14:04

Konstantin Zhuk


3 Answers

Ok, I found one solution. Idk if it is correct, but it is the simpliest one. Just need to rotate "Rect tranform" for 180 degrees. Solution in image

The video of the result: google drive.

like image 114
Konstantin Zhuk Avatar answered Nov 14 '22 15:11

Konstantin Zhuk


    yourGameObject.transform.SetAsFirstSibling(); is the solution.

Can be done at the end of other transform actions.

    button.transform.parent = ServerMessagesContent.transform;
    button.transform.position = ServerMessagesContent.transform.position;

    button.transform.SetAsFirstSibling();
like image 37
Shantu Avatar answered Nov 14 '22 15:11

Shantu


In the Vertical layout group(component) you can change the Child Alignment to Lower Center.

Rotating the whole UI element is not a good idea(might cause major headache down the line) and since this thread is the first thing that came up while googling, I felt I should drop this here for future devs.

like image 1
Martin Avatar answered Nov 14 '22 14:11

Martin