I want that first GameObject added to it to start from right the next left to first one and so on.
5 Answers
5I 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.
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
1. Download and Install JDK 8 : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 2. In Unity : Edit → Preferences → External Tools , then pull the bottom of this window, and you will see the Android Path Browse Button (yes it is well hidden, for nothing...) 3. Click Browse and find where you installed the JDK ( C/Programs/Java/Jdk1.8 ) One bug fixed now, have fun with the next one ^^
– SirDef11I 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:
Set the x scale of the object with the Horizontal Layout Group to -1
Set the scale of all the objects you have in the Layout Group to negative on the x as well so they orient correctly.
Not the best solution, but doesn’t require any extra components or code.
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!
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.
– Jon_BrantContent Size Filter with Horizontal Fit set to Preferred Size is exactly what fixed this for me. Thanks!
– nuxvomo