Two modules in one plugin

Hello,

Is it possible to have two (or more) modules in one plugin and if yes, how is it done?

I have found mentions that say it’s possible, but nothing concrete and everything I’ve tried ended in errors.

Background is that I want to create a plugin that relies heavily on an already existing plugin from the marketplace (the licences cover that as far as I know. Please correct me if I’m wrong). But having plugins depend on other plugins seems to be discouraged, so I want to merge them into one. Is that possible?

Thank you very much in advance.

Yes, you can have any number of modules per plug-in. Create one sub-folder within the plug-in’s Source directory for each module. The names of the sub-folders are the names of the modules. In your plug-in’s .uplugin file you then add the various modules to the “Modules” section.

You can find many examples in the UE4 code base under /Engine/Plugins. Most of the included plug-ins have multiple modules.

1 Like

Thanks for the quick answer but i cant get it to work.

(Edit: I’m very sorry but I can’t seem to get this into a more readable form.)

I tried copying the folder over so my file tree in Plugins/* now looks like:

|-TestPlugin/

| |-TestPlugin.uplugin

| |-Source/

| | |-TestPlugin/

| | | |-TestPlugin.Build.cs

| | | |-Private/

| | | |-Public/

| | |-DonAINavigation

| | | |-DonAINavigation.Build.cs

| | | |-Classes/

| | | |-Private/

| | | |-Public/

The DonAINavigation folder is from the marketplace plugin.

In the uplugin file I added the module so it looks like this:

{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "TestPlugin",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"EnabledByDefault": true,
"CanContainContent": false,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "TestPlugin",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "DonAINavigation",
"Type": "Runtime",
"LoadingPhase": "Default"
}
]
}

When I try to rebuild the solution it gives me two errors(they are in German so it
might not be the exact english ones):
System.UnauthorizedAccessException: Denied access to “F:\Dokumente\Unreal Projects\MyProject3\Plugins\TestPlugin\Binaries\Win64\UE4Editor-TestPlugin.dll”
and
MSB3073 The command “C:\Program Files\Epic Games\UE_4.13\Engine\Build\BatchFiles\Reuild.bat” MyProject3Editor Win64 Development “F:\Dokumente\Unreal Projects\MyProject3\MyProject3.uproject” -waitmutex exited with code -1.

What am I missing?

Ignore that last comment. I got it to work. (I feel a bit stupid now)
I tried to rebuild the solution but I had to “Start Without debugging”(Ctrl+F5) and building the binaries again and then hitting “Build Solution” (Ctrl+Shift+B).
(I’m writing this down, in case someone else gets stumped on this.)

I have got into a similar problem recently, (I know it is an old question, but maybe someone may fall into the same situation)

Your directory structure are ok, but it is missing the classes that instantiate your modules. In your case you need a TestPlugin.h and TestPlugin.cpp along with the TestPlugin.Build.cs, and the same applies to DonAiNavigation.

You can take a look in any other module implementation to check how is it done but it is mostly like:

#include "<plugin_name>.h"
#include "Modules/ModuleManager.h"

IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, <plugin_name>, "<plugin_name>" );

hope that helps