Search Unity

Bug Cannot set color of SpriteRenderer at runtime.

Discussion in '2D Experimental Preview' started by akuseix, Nov 9, 2016.

  1. akuseix

    akuseix

    Joined:
    Nov 9, 2016
    Posts:
    2
    I've verified that this is an issue in 5.5.0a6 and the issue does not exist in 5.4.2f2. If you have a GameObject with a SpriteRenderer and try to change the color property at runtime in a script, it will change the color of the SpriteRenderer in the Inspector but will not change the color of the sprite itself in the scene, game view or running build.

    If you manually change the color through the Inspector, it changes correctly in the scene view and game view. It is very easy to reproduce this, just create a script that changes SpriteRenderer.color in the Update function and attach it to the GameObject that has a SpriteRenderer.
     
  2. akuseix

    akuseix

    Joined:
    Nov 9, 2016
    Posts:
    2
  3. Ratatoeskr

    Ratatoeskr

    Joined:
    Oct 25, 2013
    Posts:
    6
    Can confirm. I also have this issue. It doesn''t mater weather you change the color property of the sprite renderer or change the "_Color" property of the material. Neither works.
    Today I switched back to beta 5.5 and.. tada! suddenly my animated sprite colors worked again :p
     
  4. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Already reported this with an example project using the bug reporter on 24.09.2016
    Zero reaction so far.
    case no: 834911
     
  5. Johaness_Reuben

    Johaness_Reuben

    Unity Technologies

    Joined:
    Jan 27, 2016
    Posts:
    253
    Probably something related to the version Preview2 was based on. Experimental Preview 3 is based on 5.5 beta so it should work fine.
     
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,496
    Hi.

    I have similar issue related to this.

    The changing of spriterenderer's color property does seems to work at first, but then when you change its material or shader to something else that is also based on the default sprite shader at runtime, it does not change the color of the sprite.

    I have confirmed this with changing the shader of the sprite's renderer material to the exact same copy of the default sprite shader and the shader does not receive the vertex color information from the spriterenderer.

    However, setting the _Color value of the material does seem to work.

    This happens only when you change spriterenderer's material shader into something else during runtime. Even if the changed shader is actually the same shader as the default sprite shader.

    Something odd is happening when spriterenderer's material's shader changes.. perhaps the spriterenderer is not expecting such changes during runtime?