问题
I need to change the expanding direction of the VerticalLayoutGroup. With the default behavior the group will expand downstairs. What i want is, that the group will expand upstairs.
The expected behavior is described in this Video. (Link to the answer on stackoverflow https://stackoverflow.com/a/43192904/11236801)
The solution on the link is, to rotate the LayoutGroup about 180°. Now this seems more like a workaround, because all childs have to be rotated as well. The solution suggested by this one will not give the expected behavior shown in the video.
I added the ContentSizeFitter to the LayoutGroup like described in this link in the Unity Answers. Now the LayoutGroup will expand in both directions (upstairs and downstairs).
Is there any solution to accomplish the desired behavior without rotating the LayoutGroup?
Edit: I also noticed a downside from the rotating approach: The Billboard Script from the MixedRealityToolkit will force the LayoutGroup to rotate back to 0°.
回答1:
This works for me:
Note the Child Alignment setting on the Vertical Layout Group, and the Pivot settings on the RectTransform. This makes the layout group expand upwards when more items are added.
来源:https://stackoverflow.com/questions/55279138/how-change-expanding-direction-of-verticallayoutgroup-in-unity-without-rotating