Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Why is it not accepting _Color variable?

Discussion in 'Shaders' started by Stef_Morojna, Jul 16, 2016.

  1. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Code (CSharp):
    1. Shader "Unlit Color" {
    2.  
    3.     Properties{
    4.         _Color("Color", Color) = (1,1,1)
    5.     }
    6.  
    7.         SubShader{
    8.  
    9.  
    10.         Tags{
    11.         "Queue" = "Transparent"
    12.         "IgnoreProjector" = "True"
    13.         "RenderType" = "Transparent"
    14.         "PreviewType" = "Plane"
    15.         "CanUseSpriteAtlas" = "True"
    16.     }
    17.  
    18.         Pass{
    19.  
    20.         CGPROGRAM
    21. #pragma vertex vert
    22. #pragma fragment frag
    23.  
    24. #include "UnityCG.cginc"
    25.  
    26.     struct appdata
    27.     {
    28.         float4 vertex : POSITION;
    29.         float2 uv : TEXCOORD0;
    30.     };
    31.  
    32.     struct v2f
    33.     {
    34.         float2 uv : TEXCOORD0;
    35.         float4 vertex : SV_POSITION;
    36.     };
    37.  
    38.     v2f vert(appdata v)
    39.     {
    40.         v2f o;
    41.         o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    42.         o.uv = v.uv;
    43.         return o;
    44.     }
    45.  
    46.     fixed4 frag(v2f i) : SV_Target
    47.     {
    48.         return _Color;
    49.     }
    50.         ENDCG
    51.     }
    52.     }
    53. }

    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?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,209
    Stef_Morojna likes this.
  3. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289