URP - Change camera's volume layer mask through code

Hey, how to change the volume mask through code in URP?

It should be on the “UniversalAdditionalCameraData”-script that’s attached to your camera
If you set the inspector to Debug-Mode, it makes it easier to see:

8823517--1201192--upload_2023-2-21_16-4-17.png

1 Like

Thanks! it works!

Hmm, do you know how to assign these layerMask in the script? Because I don’t know if it can be done by names, or are they assigned numerically somehow?

Like all other LayerMasks, they’re a bit-shifted int with layers in it (32 layers max).

Unity - Scripting API: LayerMask (unity3d.com)

You could use LayerMask.GetMask() with layernames if you want to do it by name(s).

1 Like