Change cameras image effects with button press

HI all,

New to Unity and trying to get a script that will allow image effects attached to the main camera to be cycled through with button presses.
At the moment I have different effects that are attached to different cameras that I can cycle through(the cameras) but it would be more efficient to have them all on the one camera object so that when I do modifications to the camera, I only have to do it once.
I have looked at the following reference:
Code:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Update() {
        OtherScript otherScript = GetComponent<OtherScript>();
        otherScript.DoSomething();
    }
}

but cant seem to work it out.
I have a BloomEffect and a EdgeDetectEffect script that I want to use.
Any advice

Cheers

If you look at the script they are using namespaces, so you are able to do “using UnitySampleAssets.ImageEffects;” Then you can correctly reference the BloomAndFlares without any extra hastle.

Example:

using UnityEngine;
using System.Collections;
using UnitySampleAssets.ImageEffects;

public class ChangeCamEffects : MonoBehaviour {

	public GameObject MainCam;

	public void DoStuff() {

		MainCam.GetComponent<BloomAndFlares> ().bloomIntensity = 1;

	}

}

Hope this helps.

I had a similar problem. The first thing you need to do is move all the Image Effects scripts that you use to \Assets\Plugins folder (make one if you don’t have it already). That way the .js files can be accessed from the .cs files (for instance, c# won’t recognize BloomAndLensFlares as a class until you do and so you can’t pass it as a component to the OtherScript variable).
After you’ve done that, all you have to do is indeed store BloomAndLensFlares (or any other image effect for that matter) in a variable (preferably cache it at the Start() or Awake() methods for more efficient code)and later change the ‘enabled’ property of the component as needed.
For example:

using UnityEngine;
using System.Collections;
using Assets.Scripts;

public class ToggleBloom : MonoBehaviour 
{
	private BloomAndLensFlares _bloomToggle;

	void Start()
	{
		_bloomToggle = transform.GetComponent("BloomAndLensFlares") as BloomAndLensFlares;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(Input.GetKeyDown("space"))
		{
			_bloomToggle.enabled = !_bloomToggle.enabled;
		}
	}
}

Now you’ll probably want to store the effects in an array and iterate over them as you press the button, but that’s the general idea.

Hope that helps!

i moved to plugins but still gives me same error
what to do?
is there a way to write the same script in javascript
im sure i wont have this problem