Custom UI cutout shader breaks parent mask?

I have tried the “solution” in this thread, UI mask with shader - Questions & Answers - Unity Discussions

But that doesn’t do it, it breaks the cutout shader and I’m not able to tweak the _Cutoff property anymore. The Image which has the new material doesn’t react on PointerClick events anymore, as if the raycast has been turned off, though it has not.

Shader "Effects/Cutout"
{
	Properties
	{
		[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
        _Cutoff ("Cutoff", Range(0,1)) = 0.5
        _EdgeRadius ("Edge Radius", Float) = 0.2

         // required for UI.Mask
         _StencilComp ("Stencil Comparison", Float) = 8
         _Stencil ("Stencil ID", Float) = 0
         _StencilOp ("Stencil Operation", Float) = 0
         _StencilWriteMask ("Stencil Write Mask", Float) = 255
         _StencilReadMask ("Stencil Read Mask", Float) = 255
         _ColorMask ("Color Mask", Float) = 15

	}
	SubShader
	{
		// No culling or depth// inside SubShader
        Tags { "Queue"="Transparent"  "IgnoreProjector"="True" }

         // required for UI.Mask
         Stencil
         {
             Ref [_Stencil]
             Comp [_StencilComp]
             Pass [_StencilOp] 
             ReadMask [_StencilReadMask]
             WriteMask [_StencilWriteMask]
         }
         ColorMask [_ColorMask]

		Pass
		{
            Cull Off 
            ZWrite Off 
            Blend SrcAlpha OneMinusSrcAlpha

			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			
			#include "UnityCG.cginc"

			struct appdata
			{
				float4 vertex : POSITION;
				float2 uv : TEXCOORD0;
			};

			struct v2f
			{
				float2 uv : TEXCOORD0;
				float4 vertex : SV_POSITION;
			};

			v2f vert (appdata v)
			{
				v2f o;
				o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
				o.uv = v.uv;
				return o;
			}
			
			sampler2D _MainTex;

            float _Cutoff;
            float _EdgeRadius;


			fixed4 frag (v2f i) : SV_Target
			{
                 fixed4 col = tex2D(_MainTex, i.uv);

                 if (col.a < _Cutoff - _EdgeRadius)
                    col.a = 0;
                 else if ( col.a < _Cutoff + _EdgeRadius)
                    col.a = (col.a - (_Cutoff - _EdgeRadius)) / (_EdgeRadius*2);
                 else
                    col.a = 1;

                 return col;
			}
			ENDCG
		}
	}
}

I made a temporary and dirty solution by creating two materials:

  1. Material with cutout shader (masking)
  2. Material with cutout shader (no masking)

Then I switch to no masking when I want to animate the cutoff value. And switch to masking when I want to mask the object.