Add Unreal Engine classes, modules, and plugins in Visual Studio

In this article, learn how to use Visual Studio Tools for Unreal Engine to:

Prerequisites

The following must be installed:

Add Unreal Engine modules in Visual Studio

You can now add Unreal Engine modules to your Unreal Engine project from within Visual Studio. You no longer have to switch between the Unreal Engine Editor and Visual Studio to add a module, or need to synchronize the Visual Studio solution with your Unreal Engine project file afterwards.

Modules are a way to organize your code in Unreal Engine. They help you group related classes and assets together and organize your code into self-contained units that can be loaded and unloaded at runtime. Creating modules can be tedious and error-prone if you do it manually because it requires editing configuration files and adding boilerplate code. Visual Studio makes it easier to create modules by providing a dialog that guides you through the process and doing the configuration and adding the boilerplate for you.

To add an Unreal Engine module in Visual Studio, follow these steps after completing Quickstart: Visual Studio Tools for Unreal Engine to download and build the Lyra game. These steps assume that you have the LyraStarterGame.sln solution open in Visual Studio:

  1. In Solution Explorer, choose a project, such as LyraStarterGame, where you want the new module to go.
  2. Right-click the project (be sure a project is selected and not a folder) and choose Add > Unreal Engine item... to open the Add New Item dialog for Unreal Engine items: A screenshot of the Add New Item menu. Empty Unreal Engine Module is selected.
  3. Choose Unreal Engine Module, provide a module name in the Name field, and then choose Add to open the Add Unreal Engine Module dialog:

    A screenshot of the Add Unreal Engine Module dialog.

    The Add Unreal Engine Module dialog has a field for the Module name, dropdowns for the Module type (Runtime is selected) and module loading phase (Default is selected). The module path, header, source, and build file paths are listed. The checkbox for Refresh IntelliSense information using Unreal Editor tools is checked.

  4. Use the drop-downs to select the Module type and Module loading phase.
  5. Choose OK to add the module to the project and update the Visual Studio solution file.

Modules can only be created in the Source folder or as a module of a plugin inside the Plugins folder.
The Build path shows where the Build.cs file is created. The Build.cs file contains configuration information for the module.

Add Unreal Engine classes in Visual Studio

You can now add Unreal Engine classes to your Unreal Engine project from within Visual Studio. You no longer have to switch between the Unreal Editor and Visual Studio to add a class, or need to synchronize the Visual Studio solution with your Unreal Engine project file afterwards.

To add an Unreal Engine class in Visual Studio, follow these steps after completing Quickstart: Visual Studio Tools for Unreal Engine to download and build the Lyra game. The steps assume that you have the LyraStarterGame.sln solution open in Visual Studio:

  1. In Solution Explorer, choose a folder where you want the new class to go. In the LyraStarterGame project, you could add a new class to the LyraStarterGame > Source folder, for example.
  2. Right-click the folder and choose Add > Unreal Engine item... to open the Add New Item dialog:

    A screenshot of the Add New Item dialog, with Unreal Engine Common Classes selected.

    It has options for adding an Unreal Engine Common Classes (which is selected), Empty Unreal Engine Module, and Unreal Engine Plugins.

  3. Choose Unreal Engine Common Classes and then choose Add to open the Add Unreal Engine Class dialog:

    A screenshot of the Add New Unreal Engine class dialog.

    Options for selecting a base such as Actor, Character, and so on, are visible. There's a field for the class name and a dropdown for the module to add the class to. The paths to the header file and source file are listed. A checkbox is selected to refresh IntelliSense information using Unreal Editor tools.

  4. Choose a Class name. Visual Studio warns you if the name conflicts with an existing class or file.
  5. Choose a Base class. Selecting a base class ensures that the right headers and macros are included for that class type.
  6. Choose a module to add to your class to using the Select a module to add the class dropdown. The module name is the name of the folder that contains the module.
  7. Select the Refresh IntelliSense information using Unreal Editor tools checkbox to choose whether Visual Studio uses Unreal Editor tools to update the IntelliSense information. Choose this to cause the Unreal Build Tool to regenerate the Visual Studio solution file.
  8. Choose OK to generate the header and source files for the new class and add them to the Visual Studio solution file. This results in a prompt to reload the project. Choose Reload to reload the project.

Add Unreal Engine plugins in Visual Studio

You can now add Unreal Engine plugins to your Unreal Engine project from within Visual Studio. You no longer have to switch between the Unreal Editor and Visual Studio to add a plugin, or need to synchronize the Visual Studio solution with your Unreal Engine project file afterwards.

To add an Unreal Engine plugin in Visual Studio, follow these steps after completing Quickstart: Visual Studio Tools for Unreal Engine to download and build the Lyra game. The steps assume that you have the LyraStarterGame.sln solution open in Visual Studio:

  1. In Solution Explorer, choose a folder where you want the new plugin to go. In the LyraStarterGame project, you could add a new plugin to the LyraStarterGame > Source folder, for example.
  2. Right-click the folder and choose Add > Unreal Engine item... to open the Add New Item dialog:

    A screenshot of the Add New Item dialog, with Unreal Engine Plugins selected.

    It has options for adding an Unreal Engine Common Classes, Empty Unreal Engine Module, and Unreal Engine Plugins (which is selected).

  3. Choose Unreal Engine Plugins and then choose Add to open the Add Unreal Engine Plugin dialog:

    A screenshot of the Add New Unreal Engine plugin dialog.

    There's a list of Plugin types (Advanced is selected), and fields for the plugin name, path, author, description, and URL. There's an Is plugin in beta checkbox (unchecked) and a Refresh IntelliSense information using Unreal Editor Tools checkbox (checked).

  4. Choose the type of your plugin from the Plugin type list.
  5. Provide the Plugin name, Plugin author, Plugin Description, and Plugin url.
  6. Check the Is plugin in beta box as needed.
  7. Select the Refresh IntelliSense information using Unreal Editor tools checkbox to choose whether Visual Studio uses the Unreal Editor tools to update the IntelliSense information. This causes the Unreal Build Tool to regenerate the Visual Studio solution file.
  8. Choose Add to generate the plugin header and source files for the new plugin and add them to the Visual Studio solution file. This results in a prompt to reload the project. Choose Reload to reload the project.

Visual Studio Tools for Unreal Engine
View Unreal Engine Blueprints in Visual Studio
View Unreal Engine logging in Visual Studio
View Unreal Engine macros in Visual Studio