Search Unity

Syntax error: unexpected token '}'

Discussion in 'Shaders' started by JaniFucka, May 17, 2018.

  1. JaniFucka

    JaniFucka

    Joined:
    Apr 26, 2018
    Posts:
    5
    Hey guys, my first post here!

    I've been following a YouTube video on creating an outline shader and ended up with a script that, to me, looks line for line identical to the one in the video (before you ask, no, source code was not provided, hence writing it by myself).

    After saving it, I keep getting the error:
    "Shader error in 'Burja/ShaderTest': syntax error: unexpected token '}' at line 55 (on d3d11)"

    Adding a semicolon results in error:
    "Shader error in 'Burja/ShaderTest': syntax error: unexpected end of file at line 56 (on d3d11)"

    while deleting the bracket produces error:
    "Shader error in 'Burja/ShaderTest': syntax error: unexpected end of file at line 55 (on d3d11)"

    Any ideas? I really need help with this...

    I should probably state that I'm a 3D artist and this is the first code I've writen in my life. I've seen a couple of videos on coding before and this video makes it really easy to understand what's going on while following and writing, but I don't yet have any idea how to solve errors on my own.

    Oh, and I'm using Unity 2017.3.0 with Visual Studio 2017


    Code (CSharp):
    1. Shader "Burja/ShaderTest"
    2.      {
    3.          Properties
    4.          {
    5.              _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
    6.              _MainTex ("Texture", 2D) = "white" {}
    7.              _OutlineColor("Outline Color", Color) = (0,0,0,1)
    8.              _OutlineWidth("Outline Width", Range(1.0,5.0)) = 1.01
    9.          }
    10.    
    11.          CGINCLUDE
    12.          #include "UnityCG.cginc"
    13.    
    14.          struct appdata
    15.          {
    16.              float4 vertex : POSITION;
    17.              float3 normal : NORMAL;
    18.          };
    19.    
    20.          struct v2f
    21.          {
    22.              float4 pos : POSITION;
    23.              float3 normal : NORMAL;
    24.          };
    25.    
    26.          float _OutlineWidth;
    27.          float4 _OutlineColor;
    28.    
    29.          v2f vert(appdata v)
    30.          {
    31.              v.vertex.xyz *= _OutlineWidth;
    32.    
    33.              v2f o;
    34.              o.pos = UnityObjectToClipPos(v.vertex);
    35.              return o;
    36.          }
    37.    
    38.          ENDCG
    39.    
    40.          SubShader
    41.          {
    42.              Tags{ "Queue" = "Transparent"}
    43.    
    44.              Pass // Render The Outline
    45.              {
    46.                  ZWrite Off
    47.    
    48.                  CGPROGRAM
    49.                  #pragma vertex vert
    50.                  #pragma fragment frag
    51.    
    52.                  half4 frag(v2f i) : COLOR
    53.                  {
    54.                      return _OutlineColor
    55.                  }
    56.                  ENDCG
    57.              }
    58.    
    59.              Pass // Normal Render
    60.              {
    61.                  ZWrite On
    62.    
    63.                  Material
    64.                  {
    65.                      Diffuse[_Color]
    66.                      Ambient[_Color]
    67.                  }
    68.    
    69.                  Lighting On
    70.    
    71.                  SetTexture[_MainTex]
    72.                  {
    73.                      ConstantColor[_Color]
    74.                  }
    75.    
    76.                  SetTexture[_MainTex]
    77.                  {
    78.                      Combine previous * primary DOUBLE
    79.                  }
    80.              }
    81.          }
    82.      }
    83.    
    84.  
     
  2. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    314
    line 54 is missing ;
    return _OutlineColor;
     
  3. JaniFucka

    JaniFucka

    Joined:
    Apr 26, 2018
    Posts:
    5
    I feel like an idiot now...
    Thank you so much!