Search Unity

Creating any material gives a shader error on empty project #SOLVED

Discussion in 'Scripting' started by madpuppet, May 1, 2015.

  1. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    12
    On a clean install of Unity 5, when I make a new empty project, than add a single "new script" component which just has

    Code (CSharp):
    1.  
    2. void Start ()
    3. {
    4.      new Material("pork");
    5. }
    6.  
    When I run, I get the error.

    Shader error in '': Parse error: syntax error at line 1

    I've not seen this in my last project which was fairly huge and did material creation, but on a new project that needs dynamic material creation I'm unable to get it going because this comes up all the time.
    Happens where there is a "pork" material or not.

    This is happening for me in both unity 4.5 and unity 5.


    EDIT: Argh. My Bad. So the string is the actual shader, not the name of the resource.
    Doh!
     
    Last edited: May 1, 2015
  2. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    12
    oops. turns out I had made a big assumption about what new Material() does based on previous engines I'd worked with.
    The string parameter is the actual text for the shader, not the name of the material to create.