Changing post-processing profile via scripting

Can somebody tell me how I could change the profile of the unity’s post-processing stack, via scripting. For example, when I press F I want to switch from normal camera profile to nightvision profile.

2 Answers

2

public PostProcessingProfile nightvisionProfile;

void Update () {
  if(Input.GetKeyDown(KeyCode.F)) {
    ppp = GetComponent<PostProcessingBehaviour>().profile = nightvisionProfile;
  }
}

well, I also had to write: using UnityEngine.PostProcessing

–

Updating the answer:

using UnityEngine.Rendering.PostProcessing;     

public PostProcessingProfile profile;
    
Camera.main.GetComponent<PostProcessVolume>().profile = profile;

the question is marked as answered by the person asking the question making it completely logical

–