UIGU源码分析13:MaskGraphic

本文详细探讨了Unity中的MaskGraphic类,它如何与IClippable和IMaskable接口交互,以及如何配合RectMask2D实现对象裁剪与遮罩效果。讲解了SetClipRect、RecalculateClipping和RecalculateMasking等关键方法的工作原理。

源码13:MaskGraphic

public abstract class MaskableGraphic : Graphic, IClippable, IMaskable, IMaterialModifier
{
	...    
}

继承MaskGraphic 的有Image Text RawImage 基本可以使用显示的UI组件都继承了MaskGraphic

MaskableGraphic除了继承Graphic外 还继承了三个接口


IClippable

IClippable 被裁剪者 通常和裁剪者IClipper配套使用 看IClippable接口的源码注释

   public interface IClippable
    {
        /// <summary>
        ///可被裁剪的对象
        /// GameObject of the IClippable object
        /// </summary>
        GameObject gameObject { get; }

        /// <summary>
        ///可被裁剪的父对象状态发生变化的时候使用
        /// Will be called when the state of a parent IClippable changed.
        /// </summary>
        void RecalculateClipping();

        /// <summary>
        /// 可被裁剪的对象RectTransform
        /// The RectTransform of the clippable.
        /// </summary>
        RectTransform rectTransform { get; }

        /// <summary>
        /// 在给给定的裁剪范围中进行裁剪计算
        /// Clip and cull the IClippable given a specific clipping rect
        /// </summary>
        /// <param name="clipRect">The Rectangle in which to clip against.</param>
        /// <param name="validRect">Is the Rect valid. If not then the rect has 0 size.</param>
        void Cull(Rect clipRect, bool validRect);

        /// <summary>
        /// 设置可被裁剪的对象的裁剪范围
        /// Set the clip rect for the IClippable.
        /// </summary>
        /// <param name="value">The Rectangle for the clipping</param>
        /// <param name="validRect">Is the rect valid.</param>
        void
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值