Question: Material <materialName> doesn't have _Stencil property

Hi guys. Im working on writing a shader to add little black meters for a health bar component that Im creating. The shader itself works perfectly. Here is a screenshot:

However, every time the project compiles, I get this warning:
Material StatusBar doesn't have _Stencil property

I have seen other people with the same issue

The solution is to add all of the required stencil properties to fix the warning, although they aren’t needed in their shader. When I do the same thing, the warning is gone; however the shader completely hides all of the black bars as if I hadn’t even written the shader. Maybe the stencil is completely masking all of my shader changes?

Here is my shader’s code:

 Shader "Sprites/StatusBar"
 {
     Properties
     {
        [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
        [Header(Border)]_BorderColor ("Border color", Color) = (0.1,0.1,0.1,1)
        _BorderWidth ("Border width", Float) = 1
        _Steps ("Steps", Float) = 1
        _SmallStepsPerLargeStep ("Small steps per large Step", Float) = 1
        _SmallStepHeight ("Small step height", Float) = 0.4
        [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
     
        _ImageSize ("Image Size", Vector) = (100, 100, 0, 0)
     }
 
     SubShader
     {
         Tags
         { 
             "Queue"="Transparent" 
             "IgnoreProjector"="True" 
             "RenderType"="Transparent" 
             "PreviewType"="Plane"
             "CanUseSpriteAtlas"="True"
         }
 
         Cull Off
         Lighting Off
         ZWrite Off
         Blend One OneMinusSrcAlpha
 
         Pass
         {
         CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile _ PIXELSNAP_ON
             #include "UnityCG.cginc"
             
             struct appdata_t
             {
                 float4 vertex   : POSITION;
                 float2 texcoord : TEXCOORD0;
             };
 
             struct v2f
             {
                 float4 vertex   : SV_POSITION;
                 half2 texcoord  : TEXCOORD0;
             };
             
             fixed4 _BorderColor;
             half _BorderWidth;
             half _Steps;
             half _SmallStepsPerLargeStep;
             half _SmallStepHeight;
 
             v2f vert(appdata_t IN)
             {
                 v2f OUT;
                 OUT.vertex = UnityObjectToClipPos(IN.vertex);
                 OUT.texcoord = IN.texcoord;
                 #ifdef PIXELSNAP_ON
                 OUT.vertex = UnityPixelSnap (OUT.vertex);
                 #endif
 
                 return OUT;
             }
 
             sampler2D _MainTex;
             float4 _ImageSize;
 
             fixed4 frag(v2f IN) : SV_Target
             {
                 fixed4 c = tex2D(_MainTex, IN.texcoord);
                 half stepWidth = _ImageSize.x / _Steps;
                 half xCoordinate = IN.texcoord.x * _ImageSize.x;
                 half stepIndex = xCoordinate / stepWidth;

                 if(xCoordinate % stepWidth >= stepWidth - _BorderWidth)
                 {
                     c *= _BorderColor; 
                     if (stepIndex % _SmallStepsPerLargeStep < _SmallStepsPerLargeStep - 1 && IN.texcoord.y < _SmallStepHeight) 
                     {
                         c.a = 0;
                     }
                 }
                 else
                 {
                     c.a = 0;
                 }   
                 
                 c.rgb *= c.a;
                 return c;
             }
         ENDCG
         }
     }
 }

Here are the stencil properties that I tried adding, that then break the shader

// Properties
_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

Is there any way to either hide the warnings just for this shader? Or is there a way to modify these stencil properties so that they dont break my shader?

this one is easy luckily. you didn’t initialize it in the sub shader, only the properties, so just mirror the area around 52-56 with your stencil variables.