Changing Tonemapping at runtime through C#

Hello,

I’m making an in-game level editor and I’m offering the ability to adjust the post processing per level. I’m accessing the PostProcessVolume and using TryGetSettings<>. I’ve been able to successfully use this for all settings (Bloom, AO, etc), but I can’t get this working for Tonemapping.

Trying to use TryGetSettings(), or any other way to grab it results in:

"There is no boxing conversion from 'UnityEngine.Rendering.PostProcessing.Tonemapper' to 'UnityEngine.Rendering.PostProcessing.PostProcessEffectSettings'
I understand why I’m getting this error, but I don’t quite understand why there isn’t a PostProcessEffectSettings for Tonemapping, or if there is, is it going by some other name which I’m not picking up on?

So, in summary, how do I toggle and change the Tonemapping setting on a Post Process Volume at runtime?

Thanks!

(Using 2019.3.10f1 and URP 7.3.1 with forward rendering)

For anyone looking in the future, I figured it out.
Turns out I was using the wrong kind of method of grabbing the post processing info.

I was meant to be using “UnityEngine.Rendering.Universal” instead of “UnityEngine.Rendering.PostProcessing”

I switched it to that, and got the profile using “UnityEngine.Rendering.VolumeProfile”

Had a “Tonemapping tonemappingRef”

Used “TryGet (out tonemappingRef)”

Then I was able to edit the settings by calling “tonemappingRef.mode.value = TonemappingMode.ACES”

Found that out thanks to this thread I stumbled upon

1 Like