一、简介
RectMask2D继承了UIBehaviour, IClipper, ICanvasRaycastFilter。二维矩形遮罩,允许对遮罩外的区域进行剪裁/遮罩
二、功能
1、OnEnable()
1、m_ShouldRecalculateClipRects设置为true,该变量表示当前是否需要对m_Clippers重新获取设置,
2、ClipperRegistry注册脚本对象,ClipperRegistry会在EventSystetem的PerformUpdate()函数中执行,也就是canvas渲染之前的回调中执行。
3、调用MaskUtilities.Notify2DMaskStateChanged,重新计算裁剪
protected override void OnEnable()
{
base.OnEnable();
m_ShouldRecalculateClipRects = true;
ClipperRegistry.Register(this);
MaskUtilities.Notify2DMaskStateChanged(this);
}
2、OnDisable()
清空m_ClipTargets,m_Clippers,从ClipperRegistry中删除,调用MaskUtilities.Notify2DMaskStateChanged,重新计算裁剪
protected override void OnDisable()
{
// we call base OnDisable first here
// as we