Custom Shader Giving Unexpected token error for period ' . '

So I was following along with this video and I have the same code as at around the 27th minute, 18th second:

The above is from the video at the referenced moment

When I build in MonoDevelop or VS2017, there is no error. This is my code

However, when my console gives this error:
Shader error in ‘.ShaderLive/Fixed Unlit’: syntax error: unexpected token ‘.’ at line 20 (on d3d11)

If I remove either of the . (periods) on the line , then other errors pop up. Any idea what I’m doing wrong?

Here is your working shader :

Shader ".ShaderLive/Fixed Unlit"
{
  SubShader
  {
    Pass
    {
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag

      #include "UnityCG.cginc"

      struct appdata 
      {
        float4 vertex : POSITION;
      };

      struct v2f 
      {
        float4 pos : SV_POSITION;
      };

      v2f vert(appdata IN) 
      {
        v2f OUT;
        OUT.pos = mul(UNITY_MATRIX_MVP, IN.vertex);
        return OUT;
      }

      fixed4 frag(v2f IN) :COLOR
      {
        return fixed4(1,0,0,1);
      }

      ENDCG
    }
  }
}

You made 2 mistakes in your code.

The first one, if you use some variables defined in UnityCG you have to include the header

#include "UnityCG.cginc"

And the second one

v2f OUT.pos = mul(UNITY_SHADER_MVP, IN.vertex);

does not really make sense : declare a struct, then initialize it.

Also, I think you want to use UNITY_MATRIX_MVP and not UNITY_SHADER_MVP.

Have fun :wink: