Enabling/Disabling Post Processing Effect scripts

Hi Everyone,

I’ve been trying to enable and disable post processing scripts like Antialias and CameraMotionBlur.
They do not have a .enabled property. I am assuming they are not derived from Monobehaviour.

In the editor of course you can just click them to disable/enable just like any other component.
How can I do it within a script? I tried also destroying them and recreating them but then of course you need to redefine them all over again so I am hoping I will find a way to enable/disable them.

Any ideas?

Thanks!

It’s awkward, but works for me

at the postporcessor i use

void OnPreprocessTexture(){
        if (!EditorPrefs.GetBool("enablePostprocessor"))
            return;
        ....
}

and then in code if i need to disable it i’ve just do

UnityEditor.EditorPrefs.SetBool ("enablePostprocessor", false);
.....
UnityEditor.EditorPrefs.SetBool ("enablePostprocessor", true);

So using .enabled does not even compile ?
Just a guess but it could be just a missing namespace.

static .enable could work (manual defined bool flag) if all of your scripts (post processor, and script where you need to disable it) located under “Editor” folder.

For javascript move the whole “Image Effects (Pro only)” - folder into “Standard Assets” - folder.
Then this all works (JS-Pseudocode):

var a: GlowEffect;
var a: BloomAndLensFlares;
var a: DepthOfFieldScatter;
var a: MotionBlur;
var a: Vignetting;
var a: ColorCorrectionLut;

a.enabled=true;

Hey. I know my answer could be irrelevant since it’s been long time but I had the same issue and your question was first result when I googled it so here’s how I solved it if anyone else came across this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.PostProcessing; //make sure to use this

public class Autism : MonoBehaviour {

public PostProcessingBehaviour _profile;

// Use this for initialization
void Start ()
{
_profile = GetComponent(); //script is in camera
}

// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown (KeyCode.M))
{
_profile.enabled = !_profile.enabled;
}
}

1 Like
using UnityEngine.Rendering.PostProcessing;
using UnityEngine;

public class PostprocessingExtension : MonoBehaviour
{
          [SerializeField]private PostProcessProfile postProcessProfile;
         
         
          void Start()
           {
                PostProcessingProfileIsEnabled(false,postProcessProfile);//true or false
           }
            private void PostProcessingProfileIsEnabled(bool isEnabled,PostProcessProfile postProcessProfile)
           {
               if(postProcessProfile == null) return;
               foreach (var item in postProcessProfile.settings)
              {
                       item.enabled.value = isEnabled;
               }
           }
}