Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trying to toggle "motion blur" in Post processing layer on active camera

Discussion in 'Scripting' started by IllTemperedTunas, Sep 20, 2019.

  1. IllTemperedTunas

    IllTemperedTunas

    Joined:
    Aug 31, 2012
    Posts:
    782
    Here's where I'm at.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Rendering.PostProcessing;
    3.  
    4. public class Options : MonoBehaviour
    5. {
    6.     MotionBlur blur;
    7.     public PostProcessVolume currentPP;
    8.     void Start()
    9.     {
    10.         blur = currentPP.GetComponent<MotionBlur>();
    11.         blur.enabled.Override(true);
    12.     }
    13.  
    14.     void Update()
    15.     {
    16.         if (Input.GetKeyDown(KeyCode.B))
    17.             if (blur.enabled) blur.active = false;
    18.             else blur.active = true;
    19.     }
    20. }
    I'd like to toggle motion blur on/off for the active post process volume but finding it more difficult than anticipated.

    Not sure how to access the motion blur component of the layer.

    Poked around here looking for an answer but didn't really find a solution: https://github.com/Unity-Technologies/PostProcessing/wiki/Manipulating-the-Stack

    Any help is appreciated
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    When I've tried to modify post process volumes during game play I've been generally unsuccessful. What I went with was just putting anything I want to toggle on/off on its own post processing volume where I could disable the entire volume. I was using an earlier version of the V2 stack last I tried this though, so don't know if this has been improved.
     
    IllTemperedTunas likes this.
  3. IllTemperedTunas

    IllTemperedTunas

    Joined:
    Aug 31, 2012
    Posts:
    782
    Right on, this makes sense i'll look into it!
     
    Joe-Censored likes this.