Why is it not accepting _Color variable?

Shader "Unlit Color" {

    Properties{
        _Color("Color", Color) = (1,1,1)
    }

        SubShader{

  
        Tags{
        "Queue" = "Transparent"
        "IgnoreProjector" = "True"
        "RenderType" = "Transparent"
        "PreviewType" = "Plane"
        "CanUseSpriteAtlas" = "True"
    }

        Pass{
  
        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;
    }

    fixed4 frag(v2f i) : SV_Target
    {
        return _Color;
    }
        ENDCG
    }
    }
}

So i’m trying to write a really basic fill with 1 color shader.

The problem is the line 48 is giving me error, why is it not accepting the variable _Color from Properties?

You need a fixed4 _Color; someplace inside the CGPROGRAM block but outside a function.

1 Like

Thanks!