How change expanding direction of VerticalLayoutGroup in Unity without rotating?

我的梦境 提交于 2019-12-12 13:31:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!