- Home /
Question by
$$anonymous$$ · Oct 14, 2017 at 03:12 AM ·
variableimagecomponentalpha
Change image alpha of a raw image component stored as a variable
Hello. I have a raw image component that I am storing as a variable, and I would like to change its alpha with something like "VarImage.ImageAlpha = 90;" but it seems to not be working out that way.
Comment
Best Answer
Answer by FlyingHighUp · Oct 14, 2017 at 03:20 AM
Go
float alpha = 1.0f; //1 is opaque, 0 is transparent
Color currColor = rawImage.color;
currColor.a = alpha;
rawImage.color = currColor;
Or use
float alpha = 1.0f;
rawImage.CrossFadeAlpha(alpha,durationInSeconds,false);
For a simple cross fade.
The problem turned out to be that I was storing the raw image as a component and not a color. Thanks.
Your answer
Follow this Question
Related Questions
How can I add multiple images to one gameobject 0 Answers
Blending two Texture2D 1 Answer
...FirstPersonController.m_WalkSpeed is inaccessible due to its protection level 0 Answers
can I set a variable for a component to null 1 Answer
Storing the alpha value of a canvas object to a variable 1 Answer