Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change unity Lighting Ambient color Intensity at runtime?

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);

enter image description here

like image 916
Arun kumar Avatar asked Sep 14 '25 17:09

Arun kumar


1 Answers

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);
like image 52
Programmer Avatar answered Sep 17 '25 09:09

Programmer