源码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

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

被折叠的 条评论
为什么被折叠?



