How to set project settings via C++?

Is there a way to assign/create input settings via C++?
Im talking about setting the Inputs that get set in the Project Settings. (MoveForward - “A” - Value 1), not the action binding.

Id like to create a template code that I can add to the gamemode which will create the inputs(when game starts), which I can later use when I create my character class and bind what was created.

side question:
In general, how do I get/set things in the project settings? ie, DefaultPawn, Physics Settings(Gravity Z, 2d Physics)…and so on.

thanks

-Nick

Have a look at Rama’s keybinding tutorial - it contains the functionality you need.

As for the side question, I have no idea - I think in UE3 there were ini file settings for some of those, maybe worth having a look.

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.

3 Likes

(post deleted by author)

In UE 5.4,those code work for me.

URendererSettings* RendererSettings = GetMutableDefault<URendererSettings>();
	RendererSettings->bDefaultFeatureAutoExposure = !RendererSettings->bDefaultFeatureAutoExposure;
	FPropertyChangedEvent PropertyChangedEvent(URendererSettings::StaticClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(URendererSettings, bDefaultFeatureAutoExposure)));
	RendererSettings->PostEditChangeProperty(PropertyChangedEvent);
	RendererSettings->SaveConfig();