- Home /
How to avoid color multiplication with UI.Graphic.CrossFadeColor?
I'm trying to create a highlight system in which I flash an image yellow, before fading the color back to the original color.
public Image highlightImage;
Color yellowCollor = new Color(1f, 0.96f, 0.34f, 1f);
Color originalColor;
void Start() {
if (highlightImage == null)
highlightImage = GetComponent<Image>();
originalColor = highlightImage.color;
}
public void Highlight() {
highlightImage.color=yellowCollor;
highlightImage.CrossFadeColor(originalColor, 2f, true,true);
}
The image correctly flashes yellow, but fades to a mix of the original color and yellow. I've come to understand that this is because of how the Standard UI shader multiplies colors when trying to change them. I've tried changing the OUT.color =v.color* _Color; line in the standard UI shader, but _Color doesn't seem to do anything.
(I can't use the button highlight system, because the click is wholly separate from the image that needs to be highlighted)
So, how can I just replace the color of an image using UI.Graphic.CrossFadeColor? How can I avoid the multiplication that occurs?
Your answer
Follow this Question
Related Questions
Image UI color not changing when sprite is set via script 0 Answers
Check if an image has been clicked 1 Answer
How can I change color of an Image in script (png source) ? 1 Answer
Matching the size of UI elements with that of world objects 0 Answers
UI image with button component not tracking mouse correctly 1 Answer