Add Unreal Engine classes, modules, and plugins in Visual Studio
In this article, learn how to use Visual Studio Tools for Unreal Engine to:
- Add Unreal Engine modules in Visual Studio
- Add Unreal Engine classes in Visual Studio
- Add Unreal Engine plugins in Visual Studio
Prerequisites
The following must be installed:
- Visual Studio version 17.11 (17.11 preview versions ok) or later.
- Unreal Engine version 5 or later.
- Visual Studio Tools for Unreal Engine. See Install Visual Studio Tools for Unreal Engine for installation instructions.
- Complete the Quickstart: Visual Studio Tools for Unreal Engine to download and build the Lyra game and configure it to use Visual Studio Tools for Unreal Engine.
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:
- In Solution Explorer, choose a project, such as LyraStarterGame, where you want the new module to go.
- 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:
- Choose Unreal Engine Module, provide a module name in the Name field, and then choose Add to open 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.
- Use the drop-downs to select the Module type and Module loading phase.
- 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:
- 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.
- Right-click the folder and choose Add > Unreal Engine item... to open the Add New Item dialog:
It has options for adding an Unreal Engine Common Classes (which is selected), Empty Unreal Engine Module, and Unreal Engine Plugins.
- Choose Unreal Engine Common Classes and then choose Add to open the Add 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.
- Choose a Class name. Visual Studio warns you if the name conflicts with an existing class or file.
- Choose a Base class. Selecting a base class ensures that the right headers and macros are included for that class type.
- 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.
- 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.
- 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:
- 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.
- Right-click the folder and choose Add > Unreal Engine item... to open the Add New Item dialog:
It has options for adding an Unreal Engine Common Classes, Empty Unreal Engine Module, and Unreal Engine Plugins (which is selected).
- Choose Unreal Engine Plugins and then choose Add to open the Add 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).
- Choose the type of your plugin from the Plugin type list.
- Provide the Plugin name, Plugin author, Plugin Description, and Plugin url.
- Check the Is plugin in beta box as needed.
- 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.
- 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.
Related content
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