For some reason Unity is not keeping the shadow map resolution that I set my directional light to use in the editor before runtime. I’m not quite sure why it’s being changed at runtime, but I want to change the shadow map resolution under the “Shadows → Shadow Map” category in my directional light data via code.
What is the proper syntax to reference the Resolution, and then to change it in code?
Sorry for necroing this. Since it shows up in Google here are some notes for future me (and others). The resolution actually operates in two modes (“custom resolution” and “level”). If you want to use the custom resolution you have to enable the override. If you want to use the levels instead then you have to disable the override.
HDAdditionalLightData data = ... ;
// Does it use "custom" resolution?
bool usesCustomResolution = data.shadowResolution.useOverride;
// Enable and set "custom" resolution.
data.SetShadowResolutionOverride(true); // custom res will only take effect if enabled
data.SetShadowResolution(1024);
// Use the quality levels instead of custom resolution
data.SetShadowResolutionOverride(false); // levels will only take effect if res is disabled
data.SetShadowResolutionLevel(1);