Global Render Settings

Is it possible to set the Render Settings (Fog, Ambient Light, etc) globally instead of per scene?

I achieved this using a custom script in my game. I simply added an empty game object (which I called “Controller”) and then assigned my script. I then exposed relevant properties that can easily be set using the inspector panel.

Then save this as a prefab and drag into each scene.

Use the “Awake” message to set the lighting, etc. from the properties.

Here is how you might want to achieve this:

using UnityEngine;

public class RenderSettingsComponent : MonoBehaviour {

	public bool fog;
	public Color fogColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
	public FogMode fogMode = FogMode.ExponentialSquared;
	public float fogDensity = 0.01f;
	public float linearFogStart = 0.0f;
	public float linearFogEnd = 300.0f;
	public Color ambientLight = new Color(0.2f, 0.2f, 0.2f, 1.0f);
	public Material skyboxMaterial;
	public float haloStrength = 0.5f;
	public float flareStrength = 1.0f;
	void Awake() {
		RenderSettings.fog = fog;
		RenderSettings.fogColor = fogColor;
		RenderSettings.fogMode = fogMode;
		RenderSettings.fogDensity = fogDensity;
		RenderSettings.fogStartDistance = linearFogStart;
		RenderSettings.fogEndDistance = linearFogEnd;
		RenderSettings.ambientLight = ambientLight;
		RenderSettings.skybox = skyboxMaterial;
		RenderSettings.haloStrength = haloStrength;
		RenderSettings.flareStrength = flareStrength;

Great, I was looking if there was a solution for this. I put together a custom inspector for it so you can also copy/apply settings from a scene in the editor. So if you have the script above attached to a prefab and put it into another scene….you can apply the settings…or copy the settings from a scene, in this way you see the correct settings in the editor and not only in game.

Hope it comes handy! :slight_smile:

using UnityEngine;
using UnityEditor;
using System.Collections;

class RenderSettingsComponentInspector : Editor 

    public override void OnInspectorGUI() 
        if(GUILayout.Button("Apply To Scene")) ApplyToScene();
        if(GUILayout.Button("Copy From Scene")) CopyFromScene();


    void ApplyToScene()
        RenderSettingsComponent myTarget=(RenderSettingsComponent) target;


        UnityEngine.RenderSettings.fogColor = myTarget.fogColor;
        UnityEngine.RenderSettings.fogMode = myTarget.fogMode;
        UnityEngine.RenderSettings.fogDensity = myTarget.fogDensity;
        UnityEngine.RenderSettings.fogStartDistance = myTarget.linearFogStart;
        UnityEngine.RenderSettings.fogEndDistance = myTarget.linearFogEnd;
        UnityEngine.RenderSettings.ambientLight = myTarget.ambientLight;
        UnityEngine.RenderSettings.skybox = myTarget.skyboxMaterial;
        UnityEngine.RenderSettings.haloStrength = myTarget.haloStrength;
        UnityEngine.RenderSettings.flareStrength = myTarget.flareStrength;
    void CopyFromScene()
        RenderSettingsComponent myTarget=(RenderSettingsComponent) target;