Hi,
I’m changing the fog color and density via script, depending on what level the user chooses to play like so:
public Color color = new Color();
public Color color2 = new Color();
public Color color3 = new Color();
public Color color4 = new Color();
void Awake()
{
RenderSettings.fogDensity = 0.01F;
CapsuleCollider cCollider = GetComponent<CapsuleCollider>();
Scene currentScene = SceneManager.GetActiveScene();
string sceneName = currentScene.name;
if (sceneName == "lvl1")
{
Cursor.visible = false;
RenderSettings.fogColor = color;
RenderSettings.fogDensity = 0.02F;
}
if (sceneName == "lvl2")
{
Cursor.visible = false;
RenderSettings.fogColor = color2;
RenderSettings.fogDensity = 0.02F;
}
if (sceneName == "lvl3")
{
Cursor.visible = false;
RenderSettings.fogColor = color3;
RenderSettings.fogDensity = 0.02F;
}
if (sceneName == "lvl4")
{
Cursor.visible = false;
RenderSettings.fogColor = color4;
RenderSettings.fogDensity = 0.015F;
}
The colors are defined in the inspector and they seem to work on all levels except level 3. “lvl3” has the same as lvl 1 even though it should be a totally different color. The logical problem could be that level 3 isn’t name lvl3 but it is… I haven’t been able to find any information about the problem online, does anyone know why this is happening?
It works as it should in the inspector, its only in the build that lvl3 has the wrong color. it makes no sense