Class MaskableGraphic
A Graphic that is capable of being masked out.
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
public abstract class MaskableGraphic : Graphic, ICanvasElement, IClippable, IMaskable, IMaterialModifier
Fields
m_MaskMaterial
The stencil-modified material used when this graphic is masked.
Declaration
[NonSerialized]
protected Material m_MaskMaterial
Field Value
| Type | Description |
|---|---|
| Material |
m_ShouldRecalculateStencil
Flag indicating if the stencil value needs to be recalculated.
Declaration
[NonSerialized]
protected bool m_ShouldRecalculateStencil
Field Value
| Type | Description |
|---|---|
| bool |
m_StencilValue
The stencil reference value calculated for the current masking depth.
Declaration
[NonSerialized]
protected int m_StencilValue
Field Value
| Type | Description |
|---|---|
| int |
Properties
isMaskingGraphic
Is this graphic the graphic on the same object as a Mask that is enabled.
Declaration
public bool isMaskingGraphic { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
If toggled ensure to call MaskUtilities.NotifyStencilStateChanged(this); manually as it changes how stenciles are calculated for this image.
maskable
Does this graphic allow masking.
Declaration
public bool maskable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
onCullStateChanged
Callback issued when culling changes.
Declaration
public MaskableGraphic.CullStateChangedEvent onCullStateChanged { get; set; }
Property Value
| Type | Description |
|---|---|
| MaskableGraphic.CullStateChangedEvent |
Remarks
Called when the culling state of this MaskableGraphic either becomes culled or visible. You can use this to control other elements of your UI as culling happens.
Methods
Cull(Rect, bool)
Clip and cull the IClippable given a specific clipping rect
Declaration
public virtual void Cull(Rect clipRect, bool validRect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | clipRect | The Rectangle in which to clip against. |
| bool | validRect | Is the Rect valid. If not then the rect has 0 size. |
GetModifiedMaterial(Material)
See IMaterialModifier.GetModifiedMaterial
Declaration
public virtual Material GetModifiedMaterial(Material baseMaterial)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | baseMaterial | The original material to modify. |
Returns
| Type | Description |
|---|---|
| Material | The material with stencil settings applied. |
OnCanvasHierarchyChanged()
Called when the Canvas hierarchy changes. Updates the cached parent canvas reference.
Declaration
protected override void OnCanvasHierarchyChanged()
Overrides
Remarks
Sets flags to recalculate stencil and update the material.
OnDisable()
Called when it becomes disabled. Resets the mask material and unregisters from clippers.
Declaration
protected override void OnDisable()
Overrides
OnEnable()
Called when it becomes enabled. Marks this to recalculate the stencil and update the material.
Declaration
protected override void OnEnable()
Overrides
OnTransformParentChanged()
Called when the parent changes. Re-registers with the new canvas hierarchy and marks dirty.
Declaration
protected override void OnTransformParentChanged()
Overrides
Remarks
Sets flags to recalculate stencil and update the material.
OnValidate()
Declaration
protected override void OnValidate()
Overrides
Raycast(Vector2, Camera)
When a GraphicRaycaster is raycasting into the scene it does two things. First it filters the elements using their RectTransform rect. Then it uses this Raycast function to determine the elements hit by the raycast.
Declaration
public override bool Raycast(Vector2 sp, Camera eventCamera)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | sp | Screen point being tested |
| Camera | eventCamera | Camera that is being used for the testing. |
Returns
| Type | Description |
|---|---|
| bool | True if the provided point is a valid location for GraphicRaycaster raycasts. |
Overrides
RecalculateClipping()
See IClippable.RecalculateClipping
Declaration
public virtual void RecalculateClipping()
RecalculateMasking()
See IMaskable.RecalculateMasking
Declaration
public virtual void RecalculateMasking()
SetClipRect(Rect, bool)
Set the clip rect for the IClippable.
Declaration
public virtual void SetClipRect(Rect clipRect, bool validRect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | clipRect | |
| bool | validRect | Is the rect valid. |
SetClipSoftness(Vector2)
Set the clip softness for the IClippable.
The softness is a linear alpha falloff over clipSoftness pixels.
Declaration
public virtual void SetClipSoftness(Vector2 clipSoftness)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | clipSoftness | The number of pixels to apply the softness to |