Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Shaders: Can not create fixed function shaders using "new Material(string)" anymore.

Discussion in '5.2 Beta' started by Todd-Wasson, Aug 18, 2015.

  1. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    From the release notes:

    • Shaders: Can not create fixed function shaders using "new Material(string)" anymore. Shaders must come from assets or be fully precompiled in the editor.

    Does this mean I won't be able to do this anymore?

    Code (csharp):
    1.  
    2.         matOutboardEngine = new Material(Shader.Find("Standard"));
    3.         matOutboardEngine.CopyPropertiesFromMaterial(matBaseOutboardEngine);
    4.  
    5.  
    My game revolves around customizing vehicles which includes allowing the players to set the colors of the meshes. Is this no longer possible? Is there another way? Am I just misunderstanding the release notes possibly? Maybe what I'm doing here is ok because I'm just using Find() on the standard shader? That's all I need for my project, really.
     
  2. LeonH

    LeonH

    Joined:
    Oct 15, 2014
    Posts:
    92
    You should be fine because you are not creating a shader; you are referencing an existing shader. I believe the sort of thing that doesn't work with the new fixed function shader feature is creating a shader inline, like this:
    Code (CSharp):
    1. mat = new Material(
    2.   "Shader \"Hidden/Clear Alpha\" {" +
    3.   "Properties { _Alpha(\"Alpha\", Float)=1.0 } " +
    4.   "SubShader {" +
    5.   "  Pass {" +
    6.   "  ZTest Always Cull Off ZWrite Off" +
    7.   "  ColorMask A" +
    8.   "  SetTexture [_Dummy] {" +
    9.   "  constantColor(0,0,0,[_Alpha]) combine constant }" +
    10.   "  }" +
    11.   "}" +
    12.   "}"
    13. );
     
  3. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Ok, thanks. I think I create a shader in one spot too, but that should be no big deal to change probably. That material thing had me worried because I do it everywhere...