[UE4]Canvas Panel和Uniform Grid Panel的区别(UMG Widget)

本文介绍了Unreal Engine中UMG的两种Panel类型:CanvasPanel和UniformGridPanel。CanvasPanel适合自由布局,而UniformGridPanel则自动均匀分配子元素空间。文章对比了两者的特点,并指出CanvasPanel不适用于代码动态创建Widget的情况,除非需要绝对定位。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打开Widget蓝图,在Palette(画板)面板中,可以选择Widget最外层的Panel类型,默认已经帮你建了一个Canvas Panel,看了下文档:

https://docs.unrealengine.com/latest/INT/Engine/UMG/UserGuide/WidgetTypeReference/index.html

 

这个Canvas Panel内部不适合通过代码动态创建widget,除非你想创建的widget位置是绝对路径Canvas Panel的好处是可以任意摆放widget,Unitform Grid Panle缺点是位置相对固定,优点是可以自动对齐。官方的三消游戏项目,使用了好几个Unitform Grid Panle,没有用到Canvas Panel。两种Panel的解释如下:

 

Canvas Panel

The canvas panel is a designer friendly panel that allows widgets to be laid out at arbitrary locations, anchored and z-ordered with other children of the canvas. The canvas panel is a great widget for manual layout, but bad when you want to procedurally just generate widgets and place them in a container (unless you want absolute layout). For more information on Anchors, see the Anchors page.

 

Uniform Grid Panel

A panel that evenly divides up available space between all of its children.

 

 



 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值