虚幻引擎(UE4)UMG Clipping 裁剪系统

本文详细介绍了UE4.17版本中裁剪系统的重大改动及其工作原理,特别是UMG裁剪系统如何控制Widget内容的显示。裁剪通过边界框限制渲染对象,确保超出部分不显示。内容涵盖了不同裁剪模式的解释,如Inherit、CliptoBounds等,并提供了模式选择的指导。对于滚动界面和可编辑文本控件,设置合适的裁剪模式至关重要。
摘要由CSDN通过智能技术生成

警告:在UE 4.17版本,裁剪系统经过大改,某些情况下可能会向后不兼容。更多裁剪修改信息请查看裁剪系统文档

UMG裁剪系统采用了Slate的裁剪系统,用来控制文本、图片或者其他内容如何在Widget中显示。剪裁的工作原理是使用边界框将渲染对象(图形和文本)限制到某个区域,以便不显示该区域以外的任何对象。裁剪系统是坐标轴对齐的。

ClippingExamples.png

在这个例子中,每一个按钮是文本的父级,这些例子清楚地说明了文本是如何被按钮边界裁剪的。

  • 左边的按钮,文本没有被裁剪。
  • 中间的按钮,文本被自己的边界框裁剪。
  • 右边的按钮,文本被父节点(按钮)的边界裁剪。

    在下面的图示中,蓝色的边界线代表你的游戏屏幕将裁剪线外的任何东西。
    UMGDesigner.png
    蓝色线代表你的游戏屏幕边界线。

在引擎的4.16版本以前,控件裁剪是使用布Layout来防止画布外面的区域被渲染。所以如果一个控件的边界如果在画布外面,即使经过旋转也不会被渲染,即使在画布内的部分也不会被渲染。

例如,这些示例显示了更改前后的比较变化:

Clipping1.png

裁剪模式

你可以在Detail面板中修改控件的裁剪方式。

ClippingProperties.png

Property

Description

Inherit

使用父节点的裁剪方式

Clip to Bounds

以边界框为裁剪框,如果与其他裁剪框相交了,也会被裁剪。

Clip to Bounds - Without Intersecting

This widget clips to its bounds. It does not intersect with any existing clipping geometry, it pushes a new clipping state. Effectively allowing it to render outside the bounds of hierarchy that does clip.

This will not allow you to ignore the clipping zone that is set to Clip to Bounds - Always

 

Clip to Bounds - Always

This widget clips to its bounds. It intersects those bounds with any previous clipping area.

This clipping area cannot be ignored, it will always clip children. This is useful for hard barriers in the UI where you never want animations or other effects to break this region.

 

On Demand

This widget clips to its bound when it's Desired Size is larger than the allocated geometry the widget is given. If that occurs, it will work like Clip to Bounds.

This mode was primarily added for Text, which is often placed into containers that eventually are resized to not be able to support the length of the text. So rather than needing to tag every container that could contain text with [YES], which would result in almost no batching, this mode was added to dynamically adjust the clipping if needed. The reason not every is not set to On Demand is because not every panel returns a Desired Size that matches what it plans to render at.

其他注意事项:

  • 在绝大多数情况下,你不需要调整裁剪模式,除非你确实需要这样做(例如你确实无法确定文本的长度,而需要将文本控制在裁剪区内)。一个常见的例子就是滚动界面和可编辑的文本控件,它们需要设置裁剪方式为 Clip to Bounds,而不是Inherit(继承)

 

 

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

呦呦鹿鸣.

你的打赏是给予我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值