Installing and Configuring Visual Studio 2022 for Unreal Engine

Updated for Unreal Engine 5.1.1

Updated for Visual Studio 2022 Version 17.7.3

Installing Visual Studio 2022

If you do not already have Visual Studio 2022 installed, install it from visualstudio.microsoft.com.

Install at least these options:

offset

and

offset

and

offset

For the "Game Development with C++" workload, these are the options I use:

offset

Configuring Visual Studio 2022

Some useful options you might like to set are:

Disabling the Error List

The error list is a sort of summary generated from the build output. It contains less information than appears in the output window, and more information is always better, so just use the output window.

In Tools | Options | Projects and Solutions | General you can turn off the first option shown here:

If you do use the error list make sure you are only seeing errors from the build, not from other sources like intellisense by checking the dropdown shown below is set up "Build Only":

Disabling Hot Reload

In Tools|Options|Debugging|.NET/C++ Hot Reload disable all the Hot Reload options:

Set Solution Configurations dropdown width

Change the width of the Solution Configurations dropdown to handle the longer names used by UE:

  • right-click on the toolbar shown below, select "Customize"
  • change to the "Commands" tab
  • select "Toolbar" in the top radio button group
  • change the toolbar value from "Build" to "Standard" like so:

  • in the preview panel select "System Configurations"
  • click the "Modify Selection" button
  • change the width to 130
  • press "OK" and "Close".

The toolbar will now have changed to:

Turn on Indexing

To make sure indexed searching is enabled, go to Tools > Options > Environment > Preview Features and verify that “Enable indexing for faster find experience” is checked.

See devblogs.microsoft.com.

Turn on Macro Formatting

Visual Studio has an option to enable special code formatting when using Unreal Engine reflection and slate macros.

In the Tools | Options window search for "unreal" and select the "Unreal Engine" line as shown here and turn the option on:

See Unreal Engine Macros Formatting for C++ for more information

Configuring your project

Some features of Visual Studio integration with Unreal Engine require a plugin to be part of either your engine installation or your project.

The steps to install this plugin for a project (after you have created the project) are:

  • if the Plugins directory does not exist in the project root folder, create it
  • cd Plugins
  • git clone https://github.com/microsoft/vc-ue-extensions.git
  • edit the .uproject file and add the "VisualStudioTools" plugin to the list of enabled plugins, so it looks similar to this:
	"Plugins": [
		{
			"Name": "ModelingToolsEditorMode",
			"Enabled": true,
			"TargetAllowList": [
				"Editor"
			]
		},
		{
			"Name": "VisualStudioTools",
			"Enabled": true
		}
	]
  • run Explorer, right click on the .uproject files and "Generate Visual Studio project files"
  • if Visual Studio is running it should detect the project files have been changed, select the "Reload All" option if prompted
  • in Visual Studio recompile the project

The Naming Convention Checker

Visual Studio has an option to warn when class naming does not conform to the Unreal Engine standard.

In the Tools | Options window search for "linter" and change the "Naming Convention(experimental)" option to "Warning":

In addition to enabling this warning you need to copy a file from the VisualStudioTools plugin and add it to the project:

copy Plugins\vc-ue-extensions\Source\.editorconfig Source

The rules in the .editorconfig file apply to files lower in the directory tree, so it needs to be in the Source directory.

This will make the compilation process emit an error or warning if it finds a class name which does not conform to Unreal standards. For example this code:

UCLASS()
class MYPROJECT23_API Derived : public UObject
{
	GENERATED_BODY()
};

will cause this message:

Warning	lnt-naming-convention	Identifier does not follow the naming convention.

This message is part of the linter output and is only generated in the Error List window with the filter set to "Build + Intellisense". As such it is not very useful because:

  • above we suggested not using the Error List window because it contains spurious error messages
  • intellisense can fail with messages like:
E2998	PCH warning: an unknown error occurred.  An IntelliSense PCH file was not generated.
E2996	There are too many errors for the IntelliSense engine to function properly, some of which may not be 
visible in the editor.	

Note that rebuilding the intellense database does not fix this

  • in this particular case the compiler will emit an error anyway, failing to compile and displaying this error:
Error Class 'Derived' has an invalid Unreal prefix, expecting 'UDerived'

However this feature might have some use. With the linter options configured like this:

messages about naming conventions appear in the code window as code is edited, like this:

and suggested code corrections are available:

I also had difficulty working out whether the .editorconfig file needed to be actually added to the project or just needed to be placed in the Source directory. This article shows it being explicitly added to the project, which would be disapointing because every time you use the Unreal .uproject "Generate Visual Studio project files" function the .editorconfig file gets removed from the project.

See Unreal Engine Naming Convention Checker for C++ for more information.

References

Unreal Engine & Visual Studio

Feedback

Please leave any feedback about this article here