unity GUI Layout 组件(全)
Posted sweetxiaoma
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity GUI Layout 组件(全)相关的知识,希望对你有一定的参考价值。
【expand 扩张】【fitter 装配工】 【envelope 信封,包装】
Layout 布局 三种。 | |
Horizontal Layout Group 水平布局 |
Padding:内边距,单位像素。 Spacing:子物体间的间隔,单位像素。 Child Alignment:对齐方式。 Controls Child Size:布局组件是否控制子物体的 width / height Child Force Expand:是否自适应宽高 |
Vertical Layout Group 垂直布局 |
同上。 |
Grid Layout Group 网格布局 |
Padding:略 Cell Size(X,Y):子物体大小 Spacing(X,Y):子物体xy轴上的间隔像素 Start Corner:第一个子物体所在的角落(Upper Left、等四个角) Start Axis:子物体排列方向(Horizontal、Vertical) Child Alignment:对齐方式(左上,上中,左下等九个方向) Constraint:固定每行个数或每列个数或无。 |
子物体更多设置组件 |
|
Layout Element |
使用了三种 Group 布局组件之后,就无法控制 RectTransform 的宽高了。 LayoutElement组件 是为了单独设置该物体。 步骤: 1)勾选 父物体的Group组件的 Control Child Size,(不要勾选 Child Force Expand。不然设置的首选参数Preferred Width / Preferred Height 不会起作用。) 2)设置属性: a. Min Width / Height 最小宽高。 b. Preferred Width / Height 首选宽高 c. Flexible Width / Height ;layout 组件会把所有子物体按照 Flexible Height 的比例分配高度,如三个 Flexible Height为1,则每个子物体的高度都是 1/3 。 |
Aspect Ratio Fitter |
Aspect Mode: 1) None; 2)Width Controls Height; 由宽度根据宽高比来设置 height 3) Height Controls Width; 由height 根据宽高比设置 width 4) Fit In Parent;锁定宽高比,宽度填满父物体。 5)Envelope Parent;锁定宽高比,高度填满父物体。 |
Content Size Fitters |
需要和 Layout Element 组合使用。 Horizontal Fit: 1)MinSize,父物体的width 适应子物体的Layout Element 的最大 Min Width。 Vertical Fit: 1)略 |
以上是关于unity GUI Layout 组件(全)的主要内容,如果未能解决你的问题,请参考以下文章
Unity学习笔记 --- Unity的界面排版:初识GUI
Unity零基础到进阶 ☀️| UGUI布局组件介绍 Vertical Layout GroupHorizontal Layout Group 和 Grid Layout Group
Unity3d中UGUI组件精简复盘(十六)三大 Layout Group组件