Search Unity

URP -> Unlit/Color Shader -> Player & Build Colour Discrepancies

Discussion in 'Shaders' started by PeachyPixels, Jul 12, 2021.

  1. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    711
    Hi Everyone,

    For in-game debugging purposes, I'm using the Unlit/Color shader to change certain models when specific in-game events occur.

    For example...

    Code (CSharp):
    1. renderer.material.color = Color.red;
    2. renderer.material.shader = Shader.Find("Unlit/Color");
    Now in the player, the models change to the colours as expected.

    But in the actual builds (Windows UWP & Android IL2CPP) all models show as magenta.

    The project in question is using the URP.

    I'm sure it's me doing something silly (like the runtime shader does not use the material colour property) but would anyone be able to throw some light on this please?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    Likely has nothing to do with this being the URP or not and everything to do with the shader not being included in the build. Any shader not directly referenced by content or a serialized property will not be included in the build. You'll either want to reference the unlit shader as a property of your script component, or add it to the Always Included Shaders in the project's Graphics settings.
     
    Lion_C and PeachyPixels like this.
  3. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    711
    Thank you @bgolus That was it!

    I've added it to the include shaders section and the builds are now working as expected. Shaders is an area of Unity that I've not really explored yet, so it's good to know.

    Thanks again.