I am creating 2D game with unity. I set the ambient color at runtime of the Lighting but it is also changes the intensity of the light. how to avoid the lighting intensity value from changing?
RenderSettings.ambientLight = new Color(27, 34, 46, 0);
The RenderSettings.ambientLight
property is a type of Color
and if you read the documentation, you will see that it takes values from 0f
to 1f
and not 0
to 255
.
Color32
uses values in the 0
to 255
range:
RenderSettings.ambientLight = new Color32(27, 34, 46, 0);
But if you really want to use Color
with 0
to 255
range then just divide it by 255f
:
RenderSettings.ambientLight = new Color(27 / 255f, 34 / 255f, 46 / 255f, 0 / 255f);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With