UGUI- 单列列表(VerticalLayoutGroup)

先看再Hierarchy中的层级关系:

 

解说:Scrollbar和ScrollRect平级:是因为VerticalLayoutGroup的定位基准点是中心点.如果scrollbar放在scrollRect中会和VertialLayoutGroup冲突,放外面方便点.

   

Commponent细节:

  1. BG,Scrollbar没什么,可说,正常用即可
  2. ScrollRect:用mask做遮罩,指定scrollbar给scrollrect的Vertical Scrollbar

    参照下图:

  3. Vertical LayoutGroup:

    参考下图:

  4. 再ItemPrefab上添加Aspect Ratio Fitter;

  5. BG上添加如下脚本:

     

   

说明:

对于表中每一项:

宽度在Vertical LayoutGroup的Child Control Szie中勾选了Width

调整好高度

添加脚本Aspect Ratio Fitte设置的是:Width controller height;

表中的每一项的宽高,都会跟随父物体自适应

脚本说明:

public int count; Count是一个临界值,代表能够容纳的完整的单个项目的整数;

 

欢迎交流 : D:workhai@Outlook.com

posted on 2017-10-23 22:15  虎鲨  阅读(365)  评论(0编辑  收藏  举报

导航