Search Unity

Sometimes object spawns with wrong color (aqua ?) after first Instantiate

Discussion in 'Editor & General Support' started by R1PFake, Jan 18, 2021.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    Unity 2019.4 LTS

    I have a very simple case, a script with a prefab reference which spawns the prefab with a default Instantiate call after a key is pressed.

    Now the weird part, sometimes (totatlly random) the object will spawn with a wrong color, but it's not the usual pink error color, it's more like aqua and a few frames later it will change to the correct color.

    There is nothing in the code that touches the color or material, it's literally a default sphere with no code at all.

    A few things that I noticed:
    - It doesn't happen often, sometimes I don't see it for a whole day and sometimes I only see it every few hours
    - IF it does happen, it will only be the very first Instantiate call per Play session, every following call after the "error" will spawn the object with the correct color
    - The "error" happens in the default render pipline with a Mobile/Unlit shader but also in the URP with the URP Unlit shader, so maybe it has something to do with Unlit shaders?

    Im not sure if this is a Unity or graphic card "problem", did anyone else ever see something similar?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    This is what happens in URP when Unity is still compiling the shader... or something like that... I think :)

    I don't think it will be a problem in your build because the shaders will be precompiled.
     
    R1PFake likes this.