Is RenderSettings.ambientIntensity changeable through a script?
Hi, i would like to change the ambientIntensity value ingame dynamically. Code-wise it is working and you can see the controller changing while the game is running. But it doesn't effect the scene like when i start the game with different values for ambientIntensity.
The docs are saying:
https://docs.unity3d.com/ScriptReference/RenderSettings.htmlNote that render settings are per-scene.
Does that mean it isn't possible to change dynamically?
----------------------
//Edit 1
Someone pointed out that the "per-scene" quote means that settings won't be transfered to the next scene. Additionally i found out that RenderSettings.ambientIntensity has a get and a set accessor. If you change Ambient Source to Gradient or Color it seems to be dynamically adjustable.
----------------------
Also in addition to my answer, there is a Baking
. This, to my knowledge, happens at the beginning of the scene. This is probably what they are referring to by pre-scene. It would be possible to load the same scene with the new ambient lighting during the playback of the current scene.
I have no baking activated in my game. It's all realtime since there are no non-moving objects.
Answer by mikelortega · Jan 02, 2017 at 10:01 AM
I think RenderSettings.ambientIntensity doesn't work in Unity 5.5 and should be marked as deprecated. It worked in Unity 5.4 and previous versions. I guess you should use RenderSettings.ambientSkyColor.
Answer by SoraMahiro · Dec 16, 2016 at 08:33 PM
It is under a static category, meaning that it is determined and unchangeable. So, as for your question, yes. It is not possible to change it dynamically. However, it does belong to a class and type, so it may not be as impossible as it seems. I would look into how to deal with static members in the microsoft documents.
I'm not so sure, but to have a static being unchangeable it must be tagged as const or only have a get accessor (and no set). But the ambientIntensity variable has a get and a set accessor which suggests they should be changeable.
Answer by Jelli35 · Nov 23, 2020 at 12:14 PM
Yes, but you need to call DynamicGI.UpdateEnvironment(); for it to update during playmode ,Yes, but you have to call DynamicGI.UpdateEnvironment(); afterwards for it to update during playmode https://docs.unity3d.com/ScriptReference/RenderSettings-skybox.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612102854im_/https://answers.unity.com/themes/thub/images/avi.jpg)