- Home /
Question by
sebrobitaille · Apr 23, 2014 at 09:53 PM ·
spritecolor
Chnging the opacity of a sprite not working
I am trying the change the opacity of a sprite using the color property on the sprite. This is the code(c#):
ghostPart.gameObject.GetComponent<SpriteRenderer>().color.a = 0.5f;
but is comes up with error: Cannot modify a value type return value of 'UnityEngine.SpriteRenderer.color'.
Comment
Best Answer
Answer by Eric5h5 · Apr 23, 2014 at 09:54 PM
You can only write code like that in Unityscript; in C# you must supply the entire color.
Your answer
Follow this Question
Related Questions
changing sprite color makes sprite disappear 3 Answers
Image UI color not changing when sprite is set via script 0 Answers
Unity changes the colours of my sprite 0 Answers
How to change Sprite color with alpha mask? 0 Answers
Pixel Color Issue 1 Answer