- Home /
Question by
promant12 · Jul 08, 2019 at 04:00 PM ·
c#colorspriterenderer2d sprites
Unity is ignoring Sprite Renderer's alpha channel.
As above, Unity is constantly ignoring Sprite Renderer alpha channel changed by code. The new color is set, of course, but unfortunately, the alpha stays as it was, at 1 (or 255, as one prefer). I can change it in the inspector, tho. Is it normal?
color = new Color(1, 0.25f, 0.56f, 0.1f);
GetComponent<SpriteRenderer>().color = color;
Comment
the first value you are passing is an integer not a float, I don't know why it would be that, but might be that?
@akaBase There is no need to put the 'f' next to whole number.
I'd advise to not call the variable "color" as it's already a name of a property in SpriteRenderer. What do you get if you Degub.Log(color)?
@$$anonymous$$agso When I Debug.Log this color, alpha is shown as it should.