I will try to explain this the best I can.
I’d like to make a DLL that contains multiple plugins that I then want to use in my projects. I want the code and these functions that I have made in the DLL to be visible and accessable in the editor as normal UFunctions with parameters.
So my questions are:
How do I make sure that the DLL can get access to the Unreal library accessing its Classes, functions and variables?
How do I compile multiple plugins into a single DLL? (I don’t want any engine content in my DLL)
You include the plugins in the projects that you want to use them in and they will be compiled to either 1) dll’s in an Editor build or 2) linked into the monolith exe in a game build.
While there is sort of a path for this which supports this for the Marketplace deployment of plugins, you would still get a single dll per plugin and you need the object files to link against to build the monolith. You can’t just have dlls.
Recompiling that dll would also be a pain in the butt every time you edited one (if they’re yours) or updated them (if they’re someone else’s).
Depending on your circumstances there are really two options:
Make copies for each project. This sounds terrible but it is actually a good idea in some cases so that changes to a plugin for one project don’t cause unintended problems for another project.
You can use the “Additional Plugin Directories” support and configure all your projects to look at the same directory that contains all your shared plugins. Then when you build each project, it will build your plugins from the available source as usual. The downside here is that each project does end up with individual build artifacts (dll’s and objs). Those aren’t shared across projects.
If that’s really, really, really a deal breaker (which is probably shouldn’t be), a third option is to use a source build of the engine instead of the launcher. Then you can put your shared plugins in the Engine’s plugin directory, they’ll be available to all your projects and will have shared build artifacts. However, there are certain limitations to Engine plugins and this is a really complicated method to get what you want. Either of the other two methods are better if you have no other reason to use a source build.
Although I’d say it’s a bit quick to say that this can’t be done at all (though I don’t know how it would be done myself), you’d definitely be working against how UnrealBuildTool is designed to function. I’d suggest taking a step back and figuring out what you really need (because what you’ve asked for seems to be your imagined solution, not the original problem).
If what you need is sharing a set of plugins between a team, option 2 from @MagForceSeven sounds like your best bet. Even then though, it’s not bad for each team member to have their own copy, as one team member might need to do things like seeing if you can upgrade to a newer version of one of the plugins, and you don’t want that to prevent other people from getting work done.
Download engine source from Github, create your own “plugins” as standalone apps within the Unreal solution, bind to it dependency to CoreUObject module, configure the app to compile as DLL instead of exe.
Now your DLL can understand and use Unreal types.
Export a public /include/ lib of headers for others to import your DLLs methods.
Ship.
The DLL can be used in non source versions of the engine too.
We have a single large plugin with contains many modules within it. Each module is its own separate dll. These dlls can depend on each other or not. They can also include engine headers where needed.
Basically just create a plugin as you normally would.
Then create sub folders for every module/dll you need. Each module has its Source and Content folders, and within Source has its own Build.cs file which outlines its dependancies.
Your big plugin that contains these modules will have each of them listen in the uplugin file its its Modules list.
In fact, a plugin comprises numerous modules, and each module (rather than the plugin itself) is compiled into a dll(win), so(linux), or another format. The plugin merely serves as a folder for managing modules, and the fundamental unit recognized by the engine is actually the module.
the DLL to be visible and accessable in the editor as normal UFunctions with parameters.
It’s important to underscore that this specific part of OP’s request CANNOT work with pure DLLs, because UBT (UnrealBuildTool) needs to parse the source code of the .h files to generate the metadata necessary for such a thing.
Of course, literally anything is possible if you modify the engine source code, but it’s “impossible” colloquially speaking.
That’s not necessarily a problem though. You can just define UFUNCTIONs in your project that wrap the DLL function calls, problem solved. For instance, if you’ve seen blueprint libraries interfacing with Steamworks, that’s how it’s done.
However, at this point you have lost most of the convenience of having a reusable DLL like that. But maybe that’s because I don’t really get what was so great about that idea in the first place. I don’t see what is so wrong with making plugins for the engine.