scripts
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace UnityEngine.UI
|
||||
{
|
||||
// Token: 0x02000061 RID: 97
|
||||
[AddComponentMenu("UI/Mask", 13)]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[DisallowMultipleComponent]
|
||||
public class Mask : UIBehaviour, ICanvasRaycastFilter, IMaterialModifier
|
||||
{
|
||||
// Token: 0x0600034D RID: 845 RVA: 0x00013FCD File Offset: 0x000123CD
|
||||
protected Mask()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x170000E6 RID: 230
|
||||
// (get) Token: 0x0600034E RID: 846 RVA: 0x00013FE0 File Offset: 0x000123E0
|
||||
public RectTransform rectTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
RectTransform rectTransform;
|
||||
if ((rectTransform = this.m_RectTransform) == null)
|
||||
{
|
||||
rectTransform = (this.m_RectTransform = base.GetComponent<RectTransform>());
|
||||
}
|
||||
return rectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E7 RID: 231
|
||||
// (get) Token: 0x0600034F RID: 847 RVA: 0x00014014 File Offset: 0x00012414
|
||||
// (set) Token: 0x06000350 RID: 848 RVA: 0x0001402F File Offset: 0x0001242F
|
||||
public bool showMaskGraphic
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ShowMaskGraphic;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.m_ShowMaskGraphic != value)
|
||||
{
|
||||
this.m_ShowMaskGraphic = value;
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E8 RID: 232
|
||||
// (get) Token: 0x06000351 RID: 849 RVA: 0x00014068 File Offset: 0x00012468
|
||||
public Graphic graphic
|
||||
{
|
||||
get
|
||||
{
|
||||
Graphic graphic;
|
||||
if ((graphic = this.m_Graphic) == null)
|
||||
{
|
||||
graphic = (this.m_Graphic = base.GetComponent<Graphic>());
|
||||
}
|
||||
return graphic;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000352 RID: 850 RVA: 0x0001409C File Offset: 0x0001249C
|
||||
public virtual bool MaskEnabled()
|
||||
{
|
||||
return this.IsActive() && this.graphic != null;
|
||||
}
|
||||
|
||||
// Token: 0x06000353 RID: 851 RVA: 0x000140CB File Offset: 0x000124CB
|
||||
[Obsolete("Not used anymore.")]
|
||||
public virtual void OnSiblingGraphicEnabledDisabled()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000354 RID: 852 RVA: 0x000140CE File Offset: 0x000124CE
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.canvasRenderer.hasPopInstruction = true;
|
||||
this.graphic.SetMaterialDirty();
|
||||
}
|
||||
MaskUtilities.NotifyStencilStateChanged(this);
|
||||
}
|
||||
|
||||
// Token: 0x06000355 RID: 853 RVA: 0x0001410C File Offset: 0x0001250C
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.SetMaterialDirty();
|
||||
this.graphic.canvasRenderer.hasPopInstruction = false;
|
||||
this.graphic.canvasRenderer.popMaterialCount = 0;
|
||||
}
|
||||
StencilMaterial.Remove(this.m_MaskMaterial);
|
||||
this.m_MaskMaterial = null;
|
||||
StencilMaterial.Remove(this.m_UnmaskMaterial);
|
||||
this.m_UnmaskMaterial = null;
|
||||
MaskUtilities.NotifyStencilStateChanged(this);
|
||||
}
|
||||
|
||||
// Token: 0x06000356 RID: 854 RVA: 0x0001418C File Offset: 0x0001258C
|
||||
public virtual bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
|
||||
{
|
||||
return !base.isActiveAndEnabled || RectTransformUtility.RectangleContainsScreenPoint(this.rectTransform, sp, eventCamera);
|
||||
}
|
||||
|
||||
// Token: 0x06000357 RID: 855 RVA: 0x000141C0 File Offset: 0x000125C0
|
||||
public virtual Material GetModifiedMaterial(Material baseMaterial)
|
||||
{
|
||||
Material material;
|
||||
if (!this.MaskEnabled())
|
||||
{
|
||||
material = baseMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform transform = MaskUtilities.FindRootSortOverrideCanvas(base.transform);
|
||||
int stencilDepth = MaskUtilities.GetStencilDepth(base.transform, transform);
|
||||
if (stencilDepth >= 8)
|
||||
{
|
||||
Debug.LogError("Attempting to use a stencil mask with depth > 8", base.gameObject);
|
||||
material = baseMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = 1 << stencilDepth;
|
||||
if (num == 1)
|
||||
{
|
||||
Material material2 = StencilMaterial.Add(baseMaterial, 1, StencilOp.Replace, CompareFunction.Always, (!this.m_ShowMaskGraphic) ? ((ColorWriteMask)0) : ColorWriteMask.All);
|
||||
StencilMaterial.Remove(this.m_MaskMaterial);
|
||||
this.m_MaskMaterial = material2;
|
||||
Material material3 = StencilMaterial.Add(baseMaterial, 1, StencilOp.Zero, CompareFunction.Always, (ColorWriteMask)0);
|
||||
StencilMaterial.Remove(this.m_UnmaskMaterial);
|
||||
this.m_UnmaskMaterial = material3;
|
||||
this.graphic.canvasRenderer.popMaterialCount = 1;
|
||||
this.graphic.canvasRenderer.SetPopMaterial(this.m_UnmaskMaterial, 0);
|
||||
material = this.m_MaskMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material4 = StencilMaterial.Add(baseMaterial, num | (num - 1), StencilOp.Replace, CompareFunction.Equal, (!this.m_ShowMaskGraphic) ? ((ColorWriteMask)0) : ColorWriteMask.All, num - 1, num | (num - 1));
|
||||
StencilMaterial.Remove(this.m_MaskMaterial);
|
||||
this.m_MaskMaterial = material4;
|
||||
this.graphic.canvasRenderer.hasPopInstruction = true;
|
||||
Material material5 = StencilMaterial.Add(baseMaterial, num - 1, StencilOp.Replace, CompareFunction.Equal, (ColorWriteMask)0, num - 1, num | (num - 1));
|
||||
StencilMaterial.Remove(this.m_UnmaskMaterial);
|
||||
this.m_UnmaskMaterial = material5;
|
||||
this.graphic.canvasRenderer.popMaterialCount = 1;
|
||||
this.graphic.canvasRenderer.SetPopMaterial(this.m_UnmaskMaterial, 0);
|
||||
material = this.m_MaskMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
return material;
|
||||
}
|
||||
|
||||
// Token: 0x040001A3 RID: 419
|
||||
[NonSerialized]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
// Token: 0x040001A4 RID: 420
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("m_ShowGraphic")]
|
||||
private bool m_ShowMaskGraphic = true;
|
||||
|
||||
// Token: 0x040001A5 RID: 421
|
||||
[NonSerialized]
|
||||
private Graphic m_Graphic;
|
||||
|
||||
// Token: 0x040001A6 RID: 422
|
||||
[NonSerialized]
|
||||
private Material m_MaskMaterial;
|
||||
|
||||
// Token: 0x040001A7 RID: 423
|
||||
[NonSerialized]
|
||||
private Material m_UnmaskMaterial;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user