///<summary> /// UV rectangle used by the texture. ///</summary> public Rect uvRect { get { return m_UVRect; } set { if (m_UVRect == value) return; m_UVRect = value; SetVerticesDirty(); } }
MaskUtilities.cs ///<summary> /// Notify all IMaskable under the given component that they need to recalculate masking. ///</summary> ///<param name="mask">The object thats changed for whose children should be notified.</param> publicstaticvoidNotifyStencilStateChanged(Component mask) { var components = ListPool<Component>.Get(); mask.GetComponentsInChildren(components); for (var i = 0; i < components.Count; i++) { if (components[i] == null || components[i].gameObject == mask.gameObject) continue;
var toNotify = components[i] as IMaskable; if (toNotify != null) toNotify.RecalculateMasking(); } ListPool<Component>.Release(components); }
MaskableGraphic.cs ///<summary> /// See IMaskable.RecalculateMasking ///</summary> publicvirtualvoidRecalculateMasking() { // Remove the material reference as either the graphic of the mask has been enable/ disabled. // This will cause the material to be repopulated from the original if need be. (case 994413) StencilMaterial.Remove(m_MaskMaterial); m_MaskMaterial = null; m_ShouldRecalculateStencil = true; SetMaterialDirty(); }
MaskUtilities.cs ///<summary> /// Notify all IClippables under the given component that they need to recalculate clipping. ///</summary> ///<param name="mask">The object thats changed for whose children should be notified.</param> publicstaticvoidNotify2DMaskStateChanged(Component mask) { var components = ListPool<Component>.Get(); mask.GetComponentsInChildren(components); for (var i = 0; i < components.Count; i++) { if (components[i] == null || components[i].gameObject == mask.gameObject) continue;
var toNotify = components[i] as IClippable; if (toNotify != null) toNotify.RecalculateClipping(); } ListPool<Component>.Release(components); }
// if the new parent is different OR is now inactive if (m_ParentMask != null && (newParent != m_ParentMask || !newParent.IsActive())) { m_ParentMask.RemoveClippable(this); UpdateCull(false); }
// don't re-add it if the newparent is inactive if (newParent != null && newParent.IsActive()) newParent.AddClippable(this);
RectMask2D.cs ///<summary> /// Add a IClippable to be tracked by the mask. ///</summary> ///<param name="clippable">Add the clippable object for this mask</param> publicvoidAddClippable(IClippable clippable) { if (clippable == null) return; m_ShouldRecalculateClipRects = true; MaskableGraphic maskable = clippable as MaskableGraphic;
if (maskable == null) m_ClipTargets.Add(clippable); else m_MaskableTargets.Add(maskable);
m_ForceClip = true; }
foreach (IClippable clipTarget in m_ClipTargets) { clipTarget.SetClipRect(clipRect, validRect); }
public Text targetText; public RenderTexture outputRt; public Material computeMaterial; // Start is called before the first frame update voidStart() { if(targetText && outputRt){ Graphics.Blit(targetText.mainTexture,outputRt,computeMaterial); } }