缩放水平布局组的子布局元素,同时保持其纵横比

塞缪尔·金鲍姆

我试图保持子元素的纵横比内水平布局集团当孩子的总宽度将超过布局集团的宽度。

给定下面的“水平布局组”,子正方形的总宽度适合于父正方形,因此无需缩放:

在此处输入图片说明

如果我们添加更多子项,并且它们的总宽度超过了布局组的宽度,但是默认情况下,它们不会相应缩放:

在此处输入图片说明

理想的结果是,它们将按比例缩放以适合布局组的宽度:

在此处输入图片说明

I have tried various configurations of settings on the Layout Group's properties and just cannot produce the desired outcome.

The closest I can get the below by checking Control Child Size: Width and setting a Layout Element component on the child and setting the preferred width and height.

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Control Child Size: Whether the Layout Group controls the width and height of its child layout elements.

Use Child Scale: Whether the Layout Group considers the scale of its child layout elements when sizing and laying out elements. Width and Height correspond to the Scale > X and Scale > Y values in each child layout element’s Rect Transform component.

Child Force Expand: Whether to force the child layout elements to expand to fill additional available space.

My brain is just not getting to the correct config.

希望我能忽略一些简单的事情。

伊吉

这是可能的:

  1. 创建一个 Horizontal Layer Group
  2. 刻度控制子项大小宽度
  3. 勾号童力展开宽度高度
  4. 在其中添加一个空的GameObject Horizontal Layer Group
  5. 在您在步骤4中创建的GameObject内添加另一个空的GameObject
  6. 将一个Aspect Ratio Fitter组件添加到您在步骤5中创建的GameObject中
  7. 设置长宽比模式适合父母

长宽比元素

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章