diff --git a/Scripts/SoftMask.cs b/Scripts/SoftMask.cs index fb2445c..3cfd2fd 100644 --- a/Scripts/SoftMask.cs +++ b/Scripts/SoftMask.cs @@ -55,6 +55,8 @@ namespace Coffee.UIExtensions [SerializeField][Range(0.01f, 1)] float m_Softness = 1; [Tooltip("Should the soft mask ignore parent soft masks?")] [SerializeField] bool m_IgnoreParent = false; + [Tooltip("Is the soft mask a part of parent soft mask?")] + [SerializeField] bool m_PartOfParent = false; //################################ @@ -111,6 +113,23 @@ namespace Coffee.UIExtensions } } + /// + /// Is the soft mask a part of parent soft mask? + /// + public bool partOfParent + { + get { return m_PartOfParent; } + set + { + if (m_PartOfParent != value) + { + m_PartOfParent = value; + hasChanged = true; + OnTransformParentChanged(); + } + } + } + /// /// The soft mask buffer. /// @@ -426,7 +445,14 @@ namespace Coffee.UIExtensions int count = s_TmpSoftMasks[depth].Count; for (int i = 0; i < count; i++) { - s_TmpSoftMasks[depth + 1].AddRange(s_TmpSoftMasks[depth][i]._children); + List children = s_TmpSoftMasks[depth][i]._children; + int childCount = children.Count; + for (int j = 0; j < childCount; j++) + { + var child = children[j]; + var childDepth = child.m_PartOfParent ? depth : depth + 1; + s_TmpSoftMasks[childDepth].Add(child); + } } depth++; } diff --git a/Shaders/Resources/SoftMask.shader b/Shaders/Resources/SoftMask.shader index e9319d2..ced2a86 100644 --- a/Shaders/Resources/SoftMask.shader +++ b/Shaders/Resources/SoftMask.shader @@ -6,7 +6,7 @@ SubShader { Cull Off ZWrite Off - Blend SrcAlpha OneMinusSrcAlpha + Blend SrcAlpha One ColorMask [_ColorMask] Pass {