Changing the global fog (image effect) color from a different script, possible?

Hi,

This seems like it should be easy but I’m having problems with it. I’m not familiar with the getcomponent so maybe I’m a little off, but here’s what I have.

I get the error: Object reference not set to an instance of an object

var fogScript;
GetComponent(GlobalFog);
    GetComponent(GlobalFog);
fogScript = GetComponent ("fogMaterial");
fogScript.gameCamera.camera.renderer.fogMaterial.SetColor ("_FogColor", Color.grey);

This may be new with unity 5, but it now uses RenderSettings.fogColor

I'm not familiar with that post process but your formatting looks a bit messy. Try something like this out:

private var fogScript : GlobalFog;

function Start () {
    fogScript = GetComponent(GlobalFog); //Camera.main.GetComponent(GlobalFog) if script is not on camera.
   fogScript.globalFogColor = Color.grey;
}