Enable/Disable Post Processing Effects

Hi there,

I would like to build a little menu to set the quality of my game. In this settings it should be possible to enable/disable effects like some post processings. Let’s say there is a Bloom Effect and I want to enable and disable this one at runtime. How can I get access to it in a script.

I found a script but it doesn’t work for me. It looks like this and I added this script to the Object, where the Bloom effect is added.

Bloom bloomLayer;

PostProcessVolume volume = GetComponent<PostProcessVolume>();
volume.profile.TryGetSettings(out bloomLayer);

How is it possible to disable this effect via script?

Thanks

It appears the Bloom object is a Component on a GameObject. Make your Bloom variable public and drag that GameObject into it, or else use either .GetComponent<Bloom>() or FindObjectOfType<Bloom>(), and once you have a valid reference, I would imagine you could enable and disable it by setting the .enabled property in code.

Disclaimer: I have not used this particular class myself but I assume it works like 99.9% of everything else in Unity3D.

Thanks, but no, that doesn’t work. I tried it before and in many different ways. That’s the reason, why I create this post. :-/

Same here. Did you manage to solve it?

i d like to know too

Take OP’s post and add this to the end:

bloomLayer.enabled.value = false;
6 Likes

I still cannot get it to work properly, the best way is probably to add each effect to its own volume and then just disable the volume gameobject. But I would like to know some better and faster options.

This worked for me

2 Likes
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;
               }
           }
}

OR

Below best solution

using UnityEngine.Rendering.PostProcessing;
using UnityEngine;

public class PostprocessingExtension : MonoBehaviour
{
          
         [SerializeField]private PostProcessLayer postProcessLayer;
       
          void Start()
           {
                SetPostProcessingLayerIsEnabled(false);//true or false
           }
          
         public void SetPostProcessingLayerIsEnabled(bool _value)
        {
            if(postProcessLayer == null) return;
               postProcessLayer.enabled = _value;
       }
}
1 Like

You saved me thanks!

[SerializeField]
private PostProcessVolume _postProcessVolume;
private AmbientOcclusion _ambientOcclusion;
private MotionBlur _motionBlur;
private Bloom _bloom;

private void Start()
{
_postProcessVolume.profile.TryGetSettings(out _ambientOcclusion);
_postProcessVolume.profile.TryGetSettings(out _motionBlur);
_postProcessVolume.profile.TryGetSettings(out _bloom);
}
public void AmbientOccOnOff(bool value)
{
_ambientOcclusion.active = value;
}
public void BloomOnOff(bool value)
{
_bloom.active = value;
}
public void MotionBlurOnOff(bool value)
{
_motionBlur.active = value;
}
}

This worked well until unity 6, now it doesn’t work anymore. It updates the checkbox but it doesn’t show in the game view until you hover the inspector fo the profile. In editor if I disable and then enable volume gameobject it fixes the issue, but not in the build.

1 Like

Any new developments on this one?
Stumbled into the same trap as @ FrenchToastFella right above and found no way to reliably dynamically enable/disable bloom in Unity 6 (6000.0.22f1). :frowning:

Grappling with the same issue in Unity 6. Bloom is disabled in the asset, but in the game view Bloom remains active.

The Volume object in the scene shows bloom disabled, but bloom in the camera is enabled. If I enable bloom on the object, the bloom in the camera disables. The volume asset in the project seems to be what is actually controlling the effect on the camera. If I disable bloom on the object in the scene, bloom is still enabled on the asset in the project. Disabling bloom on the asset in the project actually disables bloom on the camera during runtime.

I’ve resorted to creating separate Render Pipeline Assets, Renderers, and Volume Profiles. One set has Post Processing Enabled and the other has it disabled. Then each set is linked to a Quality Level and I switch Quality Levels to disable or enable Post Processing. Hoping there’s a better way…

1 Like