I'm trying to make a brightness overlay that can be changed by the user using a slider. I'm using a panel (Color is black) for the overlay and editing its alpha with the slider. The slider has a min value of 0 and max of 150, but the slider only has to be 1 or greater for the alpha of the overlay to be at full. When I print the alpha to the console, it says it's only 1, but the alpha on the overlay says is at max (Check gif if there's confusion). How do I set the alpha of an overlay through script using a slider?
Reasearch:
Looked at your code and found the problem.
Things to understand:
Color.a/Alpha min is 0.0f;
Color.a/Alpha max is 1.0f
Color.a/Alpha = float
not int
.
So change your public void ChangeBrightness(int brightness)
to public void ChangeBrightness(float brightness)
.
On your Slider, make sure that Min Value
=0 and Max Value
=1; Also make sure that Whole Numbers
is not selected.
Right now, the value from the slider is being converted into 0 or 1 due to the int
in your function parameter. That's why that weird problem is happening.