Anatomy of a Plugin
Before we dig into the code of our own plugin, let's first have a quick look at the AudioGameplayVolume
engine plugin to see an excellent example of how a plugin is structured. Feel free to check out some others on your own!
Let's break this down from top to bottom.
Main Folder
The top-most folder is the main folder for your plugin. This should be the name of your plugin.
Config
The Config
folder is for storing .ini
configuration files that define settings for the plugin. These settings are loaded when the plugin is initialized and can be modified. It is optional.
Resources
The Resources
folder is for storing assets required for the plugin, such as icons, textures, fonts, or documentation. Optional.
Note that this folder is not for assets related to gameplay logic or core functionality.
Source
This is where the magic happens! Your code goes here.
Each module in your plugin will have its own folder inside of the Source
folder. In the above example, one module is called AudioGameplayVolume
, which is the core runtime module. The other is called AudioGameplayVolumeEditor
, which is an editor module (hence the name).
Module Folders
Inside the module's folder, it is common practice to have Public
and Private
folders for storing .h
header files and .cpp
implementation files respectively. However, this is not a strict requirement and you can organize your code files in whichever way makes the most sense for your project. Have a look at other modules if you need some examples of how other plugins stay organized.
.Build.cs File
Modules are required to have a .Build.cs
file, which is for configuring how the module is compiled and specifying dependencies. This file should be named after your module and should be located in your module's main folder, as pictured above.
Plugin Descriptor File
Your plugin's main folder must contain a .uplugin
descriptor file that defines how the plugin is configured. The next page will cover how to configure all of the various settings.
Other common folders not pictured
Content
Plugins that contain assets will have a Content
folder located inside of the plugin's main folder. This is where gameplay-related assets can be stored, such as materials, sounds, animations, static meshes, etc.
Intermediate and Binaries
Code plugins may also contain folders named Intermediate
and Binaries
, which are related to the code's compilation. Intermediate
contains temporary files generated by the Unreal Build System (UBT), and Binaries
contains compiled binaries loaded by the engine.
Both folders are automatically generated by UBT when compiling. Occasionally you might run into build errors or crashes related to stale binaries. In those scenarios, you may wish to delete these folders in order to help force a clean rebuild from scratch.
Even more folders
Your plugin may include additional folders, though I recommend following the common practices outlined above.