How to change Camera Background Color through code?

I’m having a real hard time setting the camera’s background color (Clear Color) to the color I need.
The thing is: the background starts with the color I set on the inspector, but there is a point where I need to change it’s color while the game is running.
I set the new clear color of the camera using this:

this.mainCamera.getComponent(Camera).clearColor.set(168, 65, 0, 255);

The color is set correctly in the inspector, but the game doesn’t update the color to the new one:


As you can see in the picture above, the new brown-ish color appears in the inspector, but it’s not applied to the background of the game.

I don’t know how to do it.
Note: I can manually change the color while the game is running in the editor through the inspector, but if the change is made by the script, it’s just not applied.

What should I do?

Did you try

this.mainCamera.getComponent(Camera).clearColor = new Color(...)

The set function of color will not trigger the setter function of camera, you have to assign it using “=” operator