How do You Edit Post-Processing Through Script in The Latest Version of Unity?

I know there are a lot of Questions already asked about this, but they all use unity 2018 or earlier and the code does not work anymore (header files don’t exist, variable types either, etc.) and they don’t even explain how it works.

Could somebody please give a clear, up-to-date explanation on how to edit post-processing through script in the latest version of Unity? Thanks In advance! (USING URP BTW)

(for anyone curious on what the OLD code was, this is the gist of it):

     using UnityEngine.Rendering.PostProcessing; // this doesn't exist anymore
     using UnityEngine;
   
     public class VisualsManager : MonoBehaviour
     {
             public PostProcessVolume volume;
   
             private Bloom _Bloom;
   
             void Start()
             {
                     volume.profile.TryGetSettings(out _Bloom);
   
                     _Bloom.intensity.value = 0;
             }
     }

Unfortunately, this is currently pretty hard to find. The basic parts of the new post processing is part of the core render pipeline package, while the individual effects are part of the universal render pipeline package. You have to enable «Show Dependencies» in the package manager, only then the core package will appear as a «In Project» package and you can open its documentation. The universal render pipeline docs should include a prominent link to the core documentation but I couldn’t find one.

Anyway, the core package contains the Volume script and the VolumeProfile scriptable object, which allow you to access and change the effects. The individual effects are part of the universal package, e.g. Bloom.

Putting it together could look like this:

using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

var volume = target.GetComponent<Volume>();
if (volume.profile.TryGet<Bloom>(out var bloom>)) {
    bloom.intensity.overrideState = true;
    bloom.intensity.value = 2f;
}
1 Like

THANK YOU SO MUCH MAN! you would not believe how long I scoured the web for this answer! Just one quick question:

So I have to use

if (volume.profile.TryGet<Bloom>(out var bloom)) {
    bloom.intensity.overrideState = true;
    bloom.intensity.value = 2f;
}

whenever I want to change it in code right? for example I could have a button to set it to a certain value and in the function i would make there would be that line of code setting it to a certain value, correct?

Yeah. The overrideState only needs to be set once, you could already have it enabled in the profile (the checkbox on the left next to each property of an effect) or enable it via script at the beginning. You can also store the bloom reference from the the TryGet call and reuse it, so you don’t have to look it up each time.