- Home /
Can't change Alpha value of Image color
I have a function that changes the Alpha value of a UI Image.
public void ZenChangePlayButton()
{
//zen
innerRingImage.color = new Color32(255, 255, 255, 255);
outerRingImage.color = new Color32(255, 255, 0, 255);
}
public void ZenUnchangePlayButton()
{
innerRingImage.color = new Color32(255, 255, 255, 0);
outerRingImage.color = new Color32(255, 0, 0, 0);
}
However, once I am in play mode and one of these functions are called, the RGB values change, but the alpha values don't. Not even through the inspector (though the inspector works when out of play mode).
Is this related to my script, how the UI works, or is it just a Unity problem? Thanks for any insight.
Not all materials support transparency - you will need to use a material that has a shader that does. I'm unsure though why it would work when not in play mode, so this is a suggestion rather than an actual answer.
Answer by Yonal · Jul 04, 2019 at 03:41 PM
try creating an animation to change the alpha of a image
creating animations work for me every time
those objects already have animations for other purposes
why cant you add an alpha changing animation clip to that object
It worked but why can't I do something normally and change the color of a circle through script? Unity is a pain sometimes
Your answer
Follow this Question
Related Questions
(Inspector) Change Header Color 0 Answers
Issues with changing light colour 2 Answers
Canvas UI - Get Pixel Colour from Image 0 Answers
Color Array in C# 1 Answer
Fading Sprite Color According to Value 0 Answers