Refactor
parent
73321b9b62
commit
64b90da720
|
|
@ -27,10 +27,10 @@ namespace Coffee.UIExtensions
|
|||
[SerializeField] RectTransform m_FitTarget;
|
||||
[Tooltip("Fit graphic's transform to target transform on LateUpdate every frame.")]
|
||||
[SerializeField] bool m_FitOnLateUpdate;
|
||||
[Tooltip("Show the graphic that is associated with the unmask render area.")]
|
||||
[SerializeField] bool m_ShowUnmaskGraphic = false;
|
||||
[Tooltip ("Unmask affects only for children.")]
|
||||
[SerializeField] bool m_OnlyForChildren = false;
|
||||
[Tooltip("Show the graphic that is associated with the unmask render area.")]
|
||||
[SerializeField] bool m_ShowUnmaskGraphic = false;
|
||||
|
||||
|
||||
//################################
|
||||
|
|
@ -72,7 +72,6 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unmask affects only for children.
|
||||
/// </summary>
|
||||
|
|
@ -108,9 +107,9 @@ namespace Coffee.UIExtensions
|
|||
var canvasRenderer = graphic.canvasRenderer;
|
||||
if (m_OnlyForChildren)
|
||||
{
|
||||
canvasRenderer.hasPopInstruction = true;
|
||||
StencilMaterial.Remove (_revertUnmaskMaterial);
|
||||
_revertUnmaskMaterial = StencilMaterial.Add (baseMaterial, (1 << stencilDepth) - 1, StencilOp.Replace, CompareFunction.NotEqual, (ColorWriteMask)0);
|
||||
canvasRenderer.hasPopInstruction = true;
|
||||
canvasRenderer.popMaterialCount = 1;
|
||||
canvasRenderer.SetPopMaterial (_revertUnmaskMaterial, 0);
|
||||
}
|
||||
|
|
@ -171,9 +170,13 @@ namespace Coffee.UIExtensions
|
|||
_unmaskMaterial = null;
|
||||
_revertUnmaskMaterial = null;
|
||||
|
||||
var canvasRenderer = graphic.canvasRenderer;
|
||||
canvasRenderer.hasPopInstruction = false;
|
||||
canvasRenderer.popMaterialCount = 0;
|
||||
if (graphic)
|
||||
{
|
||||
var canvasRenderer = graphic.canvasRenderer;
|
||||
canvasRenderer.hasPopInstruction = false;
|
||||
canvasRenderer.popMaterialCount = 0;
|
||||
graphic.SetMaterialDirty();
|
||||
}
|
||||
SetDirty ();
|
||||
}
|
||||
|
||||
|
|
@ -182,16 +185,17 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
void LateUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
if (m_FitTarget && (m_FitOnLateUpdate || !Application.isPlaying))
|
||||
#else
|
||||
#else
|
||||
if (m_FitTarget && m_FitOnLateUpdate)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
FitTo(m_FitTarget);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
|
||||
/// </summary>
|
||||
|
|
@ -199,6 +203,7 @@ namespace Coffee.UIExtensions
|
|||
{
|
||||
SetDirty();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Mark the graphic as dirty.
|
||||
|
|
|
|||
Loading…
Reference in New Issue