How do I disable post-processing at runtime?
Asked Answered
C

1

0

On the advice of another thread, I used the name space UnityEngine.Rendering.Universal and called the following on my scene’s main camera:

var cameraData = mainCamera.gameObject.GetComponent<UniversalAdditionalCameraData>();
cameraData.renderPostProcessing = false;

This successfully unchecks the Post-processing box for the camera in the inspector–however, this appears to be a purely cosmetic effect, as it does absolutely nothing as far as actually disabling post-processing effects in the scene. Surely there is some way to accomplish this?

Coolidge answered 17/2 at 11:34 Comment(0)
I
0
  1. I managed to do this by creating a second Universal Renderer Data asset (duplicated UniversalRenderPipelineAsset_Renderer) and disabled post processing on that asset.

  2. I then added that asset into the renderer list on the Universal Render Pipeline asset (UniversalRenderPipelineAsset).

  3. I then used the following code to enable/disable post processing by setting the renderer index that the camera should use, as needed:

camera.GetUniversalAdditionalCameraData().SetRenderer(1); // Disable
camera.GetUniversalAdditionalCameraData().SetRenderer(0); // Enable
Idleman answered 15/10, 2023 at 15:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.