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

Unity 4.5 Shader compilation error ( #define macro with '\' symbol at end)

Discussion in 'Shaders' started by x-stuff, Jun 16, 2014.

  1. x-stuff

    x-stuff

    Joined:
    Apr 18, 2013
    Posts:
    7
    Hi, everyone.

    I want to share some experience with you.
    When upgraded unity to 4.5, there is some problem I found.

    When I build project to android or iOS target, there are several shader compilation errors, which has appeared from nothing. I mean, there is no error in editor, or when just click reimport on shader. Those errors happened only when I build project.

    Finally a found the reason.

    Code (csharp):
    1. #define ANY_DEFINE_NAME /* Absolutely anything ends with next line symbol '\' */ \
    2.  
    3. #define ANY_DEFINE_AFTER_NEXT_LINE_SYMBOL /*anything here*/
    Symbol '\' at the end of first #define macro is cause error when using the second #define macro

    I attached source shader code, you can repeat those errors. And steps to reproduce

    1) Create new ptoject
    2) import that code Unity4.5ShaderCompilationError.zip
    3) create new scene
    4) create 2 new objects (with renderers) and assign materials ".. with error" and ".. without error" to it. (just to be sure that unity will build and compile those materials' shaders)
    5) Press ctrl+shift+b and switch platform to android or iOS.
    6) Press ctrl+shift+b and build
    7) After biuld, see console output

    Or just watch =)



    Thank you for your attention.
    p.s. Hope it will be fixed at next versions ( Unity 4.3 has no this problem )
     

    Attached Files:

  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you submit a bug report?
     
  3. x-stuff

    x-stuff

    Joined:
    Apr 18, 2013
    Posts:
    7
    No. Not yet.
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Please submit a bug report. I saw this forum thread, but given my attention span, you have 99% probability I will forget about it tomorrow morning.
     
  5. x-stuff

    x-stuff

    Joined:
    Apr 18, 2013
    Posts:
    7
    bug report submitted
     
  6. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Do you have the case number?
     
  7. x-stuff

    x-stuff

    Joined:
    Apr 18, 2013
    Posts:
    7
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Last edited: Jun 25, 2014