- Home /
How can I make Horizontal Layout Group starts from right to left?
I want that first GameObject added to it to start from right the next left to first one and so on.
Answer by selllfocard · Oct 20, 2017 at 06:57 AM
Try to use Grid Layout Group instead of Horizontal Layout Group with the following properties
Child Alignment: (Upper/Middle/Lower) Right
Constraint: Fix Row Count
Constraint Count: 1
Answer by samra2494 · Mar 13, 2019 at 09:15 AM
I have solved your problem. lets try this Create a panel add component "Horizontal layout group" and set its "spacing" = "20" also add Component "Content Size Filter" set its "horizontal Fit" to "preferred size" Go to RectTransform on this panel and set pivot x=1 and y = 0 as show in the below screen shot
Now you are able to add Elements in this panel right to left.
[1]: /storage/temp/134664-capture.png
This worked well for me, thank you! Also, make sure you enable/disable the Horizontal Layout group component to force it to refresh positions. It didn't for me automatically, and looked very wrong.
Content Size Filter with Horizontal Fit set to Preferred Size is exactly what fixed this for me. Thanks!
Answer by hk1ll3r · Jan 07, 2020 at 09:26 AM
I extended Unity's HorizontalLayoutGroup to support RTL as well as LRT. This solution Is more flexible and cleaner than using GridLayoutGroup or re-ordering child elements.
The package is free and open source on github:
https://github.com/hk1ll3r/BidirectionalHorizontalLayoutGroup
Answer by roddles · Mar 08, 2017 at 06:54 AM
You need to reverse the order of the child game objects within the layout group. If you are programmatically moving them to the group, call newGameObject.transform.SetFirstSibling ()
after each insertion, so the first object will be the last sibling, and the last object will be the first.
I was having trouble with newest children aligning under the already existing ones in a vertical layout. Your comment saved me! Thank you! In Unity 2019 3.0f3 its newGameObjecttransform.SetAsFirstSibling();
Works perfectly!
Your answer
Follow this Question
Related Questions
Can't animate UI element whose values are controlled by a layout group 0 Answers
Trouble creating a horizontal group for Tall and Wide screen orientation! 0 Answers
Cannot set pivot for children of horizontal layout. 0 Answers
Create placeholders in grid layout group? 1 Answer
How to lock element width or height in a vertical or horizontal layout? 1 Answer