How to manipulate PostProcessing effects settings during execution with c#?

I need to change the intensity value of my current Vignette effect depending in specific conditions.

So far I haven’t been able to achieve this. Please help!

Image of what I want to achieve:

My setup:

  • Unity 2019.3.5f1 with URP implemented
  • Post Processing Package (v2) installed
  • Scene with a GameObject + Volume component with Vignette and Bloom effect overrides added
  • A monobehaviour component script in the very same GameObject from above

My monobehaviour script:

using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

public class PostProcessingHandler : MonoBehaviour
{
  private PostProcessVolume _ppv;
  private Vignette _vignette;

  // Vignette intensity values
  [SerializeField, Range(0f, 1f)]
  private float _lowIntensity = 0.25f;
  [SerializeField, Range(0f, 1f)]
  private float _highIntensity = 0.5f;

  private void Start()
  {
    _ppv = GetComponent<PostProcessVolume>();
    Debug.Log(_ppv);
  }
}

When I try to retrieve PostProcessingVolume component to get it’s profile (and further layer manipulation) I always get “null”.

Image of my setup:

I’ve seen several guides/posts and even Unity documentation but I cannot get past that starting point of getting the PostProcessingVolume component, what am i missing?

I got this working and during my search I came across this Unity answers page so if for the sake of possibly helping someone in the future here is my code taken from this video: Unity3D - Change PostProcessing In Realtime(2019) - YouTube

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;

public class PostProcessControl : MonoBehaviour
{
    // Start is called before the first frame update

    private PlayerController player;
    private Vignette vignette;
    private PostProcessVolume volume;

    void Start()
    {
        player = GameObject.Find("PlayerSprite").GetComponent<PlayerController>();

        volume = GetComponent<PostProcessVolume>();

        volume.profile.TryGetSettings(out vignette);
    }

    // Update is called once per frame
    void Update()
    {
        if (player.gameover)
        {
            vignette.intensity.value = Mathf.Lerp(vignette.intensity.value, 1, 1 * Time.deltaTime);
        }
    }
}

My set up is the same as described in the OP. Note, in the linked video its mentioned to avoid using the package manager for downloading the post processing asset. I did NOT encounter this issue with Unity 2019.2.6f1 and post-processing version 3.0.1