Change Bloom settings thru script

I’m trying to use GetComponent to change Bloom settings on runtime, with no success on retrieving the component, any idea of how can I access and change parameters thru script? my performance controller is written on C#, so it would be nice if I could implement that on it without creating a new JS script…

This is my performance control script:

using UnityEngine;
using System.Collections;

public class DMPerfCTR : MonoBehaviour {
	private GameObject[] psfx;
	private GameObject[] fog;
	private float fogdf;
	private float pefxdf;
	private int curSSAO;

	// Update is called once per frame
	void Update () {
		if(GetComponent<DataManager>().uiperformance != null){
			fogdf = GetComponent<DataManager>().fogdretu;
			pefxdf = GetComponent<DataManager> ().pefdretu;
			curSSAO = GetComponent<DataManager>().curSSAO;
		}
		//density of fog's particles
		fog = GameObject.FindGameObjectsWithTag ("Fog");
		for(int i = 0; i < fog.Length; ++i){
			fog*.GetComponent<PSperformance>().erperctAmount = fogdf;*
  •  }*
    
  •  //density of particle effects, such as explosions, fire etc...*
    
  •  psfx = GameObject.FindGameObjectsWithTag ("FXParticles");*
    
  •  for(int i = 0; i < psfx.Length; ++i){*
    

_ psfx*.GetComponent().erperctAmount = pefxdf;_
_
}_
_
//SSAO*_
* if(curSSAO == 0){*
* Camera.main.GetComponent ().enabled = false;;*
* }*
* if(curSSAO == 1){*
* Camera.main.GetComponent().enabled = true;*
* Camera.main.GetComponent ().m_SampleCount = SSAOEffect.SSAOSamples.Low;
_
}_
_
if(curSSAO == 2){_
_
Camera.main.GetComponent().enabled = true;_
Camera.main.GetComponent ().m_SampleCount = SSAOEffect.SSAOSamples.Medium;
_
}_
_
if(curSSAO == 3){_
_
Camera.main.GetComponent().enabled = true;_
Camera.main.GetComponent ().m_SampleCount = SSAOEffect.SSAOSamples.High;
_
}_
_
}_
_
}*_
I use a diferent script for AA and resolution

I found this and got it to work: How to modify variables from scripts in standard package? - Unity Answers

The key is to add this to the top of your C# script:

 //C#
 using UnityStandardAssets.ImageEffects;

So for my example, I can now access the bloom effect using this script attached to my camera or since there is a public variable to link up the game object, you can place this script on anything and use the inspector to point it to the appropriate game object.

using UnityEngine;
using System.Collections;
using UnityStandardAssets.ImageEffects;

public class cam_bloom : MonoBehaviour {

    public GameObject maincam;
    private BloomOptimized glowFX;

	// Use this for initialization
	void Start () {

        glowFX = maincam.GetComponent<BloomOptimized>();

	}
	
	// Update is called once per frame
	void Update () {

        glowFX.intensity = 2.1f;

    }
}

Hope this helps! :slight_smile: