Version:

UI Layout Fitter 组件

您可以使用 LayoutFitter 组件使元素调整自身大小以适应其内容。将此组件与提供单元格大小调整信息的其他组件一起使用,例如 Text 组件、Image 组件 (将 ImageType 设置为 Fixed), 或 Layout 组件 (Cell, Row, Column, Grid)。

要查看带有 LayoutFitter 组件的完整画布的游戏内示例,请在项目 SamplesProject 中打开关卡 UiFeatures。按 Ctrl+G 玩游戏,然后选择Components, Layout Components, Layout Fitter。按下 Esc 退出游戏。

To view that same canvas in the UI Editor, navigate to the \Gems\LyShineExamples\Assets\UI\Canvases\LyShineExamples\Comp\Layout directory and open the \fitter.uicanvas file.

fitter.uicanvas canvas

编辑布局拟合器组件

UI EditorProperties 面板中,展开 LayoutFitter 并根据需要执行以下操作:

Horizontal Fit

选中该复选框可调整元素宽度的大小以适合其内容。

Vertical Fit

选中该复选框可调整元素的高度以适合其内容。