Apply config changes edited at runtime (C++)

So I’ve figured out how to make changes to config files such as DefaultEngine.ini and in this case im making a plugin that depends on some features being enabled in the Project Settings such as CustomDepthStencil.

Using the following code:

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

I can change this value in the config files, however this is not yet applied to the currently-running game. I have to restart the game for these changes to actually take effect.

How can I apply these changes to the game that is currently running, or update them in the version of the config that is currently loaded into memory?

That config variable is bound to a CVar named “r.CustomDepth”, so you can try the following :

if (IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.CustomDepth")))
	CVar->Set(ECustomDepthStencil::EnabledWithStencil, EConsoleVariableFlags::ECVF_SetBySystemSettingsIni);

Worked like a charm, looks like I finally know where at least part of these config variables go in memory!