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.
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.
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;
}
}