How to set project settings via C++?

Here’s example code to answer the side question.

URendererSettings* Settings = GetMutableDefault<URendererSettings>();
Settings->CustomDepthStencil = ECustomDepthStencil::EnabledWithStencil;
Settings->SaveConfig();

This changes Project Settings > Engine > Rendering > Postprocessing > Custom Depth-Stencil Pass to Enabled with Stencil.

All project settings are UCLASSES with types that you can edit. You just have to find out which class your setting belongs to and the get it with GetMutableDefault and then set your property’s value and save.

I found out which class the Custom Depth-Stencil Pass setting was in by searching for the tooltip (surrounded by double quotes so you search for the complete line and not key words) you get when you hover over the setting in the Unreal Engine github repository. I searched for “Whether the custom depth pass” and found out that the Custom Depth-Stencil Pass setting was in Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h contained in a class called URendererSettings.

4 Likes