Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Ray_Arka · Apr 27, 2017 at 10:52 AM · errorshadershader programmingshaderlabshader writing

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: https://youtu.be/epixwRw80MM?t=27m18s alt text

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?

screenshot-34.png (258.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AtGfx · Apr 27, 2017 at 12:10 PM

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 ;)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ray_Arka · Apr 27, 2017 at 02:19 PM 0
Share

Woah you're a life saver man! I realised I copied over the "UNITY_SHADER_$$anonymous$$VP" code incorrectly so that wasn't the problem. But the main two you pinpointed were correct on the dot and had been bugging me for days!! I don't know how it worked on the aforementioned tutorial. Anyway, thanks a lot!!

avatar image AtGfx Ray_Arka · Apr 27, 2017 at 02:21 PM 0
Share

Ahah don't know either ! Np ;)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

141 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to set the 'ForceNoShadowCasting' SubShader Tag via shader properties or a custom material editor? 1 Answer

Is there any way to do multiple passes on a texture / in a fragment shader? 1 Answer

Shader error : unexpected $end, expecting TOK_SETTEXTURE or '}' at line 18 1 Answer

_Time in Image Effects 0 Answers

_WorldSpacePosLight0 suddenly changes when change camera position or direction 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges