How to change background colour of Main Camera in runtime setting RGBA values?

Here is my code to access and change background colour of Main Camera

Camera.main.GetComponent<Camera>().backgroundColor = new Color(228f,234f,241f,0f);

This code makes the background white and set values very much higher in inspector. What I am doing wrong?

The Color struct expects values between 0 and 1. Values higher than 1 will be clamped to 1. Think of it as the percentage of each color component. So RGB 1, 1, 1 is 100% each of RGB, which is white.

If you really want to use bytes then you can use the Color32 struct instead. It can be implicitly cast to Color so you can still assign it to the camera’s background color.

I figured it out, all I had to do was this

Camera.main.GetComponent().backgroundColor = new Color(228f/255f,234f/255f,241f/255f,0f);

to get the proper value between 0-1.