Fade Screen with Raw Image

Hello guys.

I’ve written the follwoing code:

            _alphaValue = Mathf.Lerp(_alphaValue, 255, Time.deltaTime * 2);
            fadeScreen.color = new Color(0, 0, 0, _alphaValue);

            if(fadeScreen.color.a >= 245)   
                Application.LoadLevel(1);            

where _alphaValue is float, fadeScreen is type of RawImage and its value is assigned in the inspector. The problem is, that screen fades immediately. However, fadeScreen.color.a is more than 245 in approximately 2 seconds. But in the inspector I can see it has value 255 after first frame.

Anyone knows where could be the problem?
Thanks for any help.

Hey! I remember having a similiar problem a few months ago and if I recall correctly, the alphavalue should be between 0 and 1 (1 meaning 255) so if you set it to any value over 1, unity understands this as 255. So simply adjust your values a bit to fix the code