当前位置:网站首页>UGUI——RectMask2D
UGUI——RectMask2D
2022-07-21 04:06:00 【fztfztfzt】
A 2D rectangular mask that allows for clipping / masking of areas outside the mask.
The RectMask2D behaves in a similar way to a standard Mask component. It differs though in some of the restrictions that it has.
A RectMask2D:
Only works in the 2D plane
Requires elements on the mask to be coplanar.
Does not require stencil buffer / extra draw calls
Requires fewer draw calls
Culls elements that are outside the mask area.
stay OnEnable Register yourself in ClipperRegistry,ClipperRegistry Will be in layout After calculation ,Graphic Call before updating cull Perform the culling operation
protected override void OnEnable()
{
base.OnEnable();
m_ShouldRecalculateClipRects = true;
ClipperRegistry.Register(this);
MaskUtilities.Notify2DMaskStateChanged(this);
}
//ClipperRegistry.cs
The clipping is called after layout, but before Graphic update.
public void Cull()
{
for (var i = 0; i < m_Clippers.Count; ++i)
{
m_Clippers[i].PerformClipping();
}
}
//CanvasUpdateRegistry.cs
In the constructor PerformUpdate Sign up to willRenderCanvases Entrustment
protected CanvasUpdateRegistry()
{
Canvas.willRenderCanvases += PerformUpdate;
}
private void PerformUpdate()
{
// Handle layoutout Of rebuild
..........
// now layout is complete do culling...
ClipperRegistry.instance.Cull();
// Handle Graphic Of rebuild
............
}
MaskUtilities.Notify2DMaskStateChanged(this);
- Get all the components in the child node
- exclude null Same with make One gameobject The components of
- call IClippable Component's RecalculateClipping Interface
- MaskableGraphic Rewrote UpdateClipParent Interface
- find IClippable In the parent node RectMask2D Components
- From the old record RectMask2D Remove itself from the component
- call RectMask2D Of AddClippable Interface ( If IClippable yes MaskableGraphic, take IClippable Join in m_MaskableTargets, Otherwise, join m_ClipTargets)
- to update m_ParentMask For the new RectMask2D
PerformClipping
according to m_ShouldRecalculateClipRects Get the same canvas Next , All under the same parent node RectMask2D( Get rid of canvas Of sortingorder Set RectMask2D) Here's the picture , Oval yellow RectMask2D Is the current node , All yellow RectMask2D Will be added to the list m_Clippers
FindCullAndClipWorldRect Calculate all m_Clippers The smallest area of intersection
Traverse m_ClipTargets, call SetClipRect
Traverse m_MaskableTargets, call SetClipRect(canvasRenderer.EnableRectClipping) and cull IXX Interface , It is used to obtain such components .
SetClipRect by canvasRenderer Turn on (EnableRectClipping(clipRect)) Or turn off rectangle clipping (DisableRectClipping).
/// <summary>
/// See IClippable.SetClipRect
/// </summary>
public virtual void SetClipRect(Rect clipRect, bool validRect)
{
if (validRect)
canvasRenderer.EnableRectClipping(clipRect);
else
canvasRenderer.DisableRectClipping();
}
边栏推荐
- 请问一下 flink1.15 flinksql kafka topic如果不提前创建提交作业就会失败
- One bite of Stream(5)
- 什么是渲染管道,怎么绘制3D物体
- SAFERTOS在医疗设备中的应用
- 结合源码看《我所理解的cocos2dx-3.0》—— 渲染流程
- Please tell me about flink1.15 flinksql Kafka topic. If you don't create a submission job in advance, it will fail
- Keras调用plot_model报错解决方案
- Title of graduation thesis on architectural decoration
- Uni app - plugin [app cloud packaging] installation failed! (the app cloud packaging plug-in installation fails when the app is packaged) solution
- 学习记录十一
猜你喜欢
Model graduation thesis of Construction Engineering Surveying and mapping
Mini simple version applet is delivered, which is exclusive to column users
Unity realizes character movement and camera tracking
学习记录十一
Chapter006 LCD display of FPGA learning
使用libwebp解码webp静态图片
Chapter005 serial port return of FPGA learning
One bite of Stream(3)
UGUI——Text和TextEffect
力扣打卡总结之动态规划
随机推荐
WordPress 6.0.1 新版已经发布,建议全部更新。
[Unity脚本优化] Unity magic methods
canvas记录
Optimizing graphics rendering in Unity games
RIoTBoard开发板系列笔记(八)—— 构建桌面系统
pinctrl
Graduation thesis title of power system and automation [selected]
Uni app - plugin [app cloud packaging] installation failed! (the app cloud packaging plug-in installation fails when the app is packaged) solution
回溯解决子集问题
Chapter006 LCD display of FPGA learning
TSN 802.1AS时钟同步协议测试
DC-2-靶场实践
请教一下,如果我同步的是mysql binlog的数据 并且没有加特定的日志,我怎么查看当前程序同步
SAFERTOS在医疗设备中的应用
色彩空间(2)—— YUV
kettle优化之提高MySQL读写速度
解决错误:Error: TomEE required to support EAR/EJB deployment
剑指offer专项突击版第4天
Title of graduation thesis on Thermal Power Engineering
UGUI——IndexedSet