Improve Third Party Plugin Documentation?

I have some external code I’d like to add to a UE 5 project. I see the instructions on how to create a third party plugin here:

However, creating a third party plugin from within UE creates a new plugin directory with what appears to be two different types of plugin directory trees, with two different *.build.cs files.

I will probably keep the code for the third party plugin separate from the UE project so that I can keep the unit tests with the solution containing the code.

What should I be deleting and/or changing if I just want to have a DLL and some header files? (Or should I really put the source code in here so that I can compile for other platforms?)

MyUEProject
+---Binaries
+---Build
+---Config
+---Content
+---Plugins
|   \---MyPlugin
|       |   MyPlugin.uplugin
|       |   
|       +---Binaries
|       +---Content
|       +---Intermediate
|       +---Resources
|       \---Source
|           +---MyPlugin
|           |   |   MyPlugin.Build.cs
|           |   |   
|           |   +---Private
|           |   |       MyPlugin.cpp
|           |   |       
|           |   \---Public
|           |           MyPlugin.h
|           |           
|           \---ThirdParty
|               \---MyPluginLibrary
|                   |   ExampleLibrary.cpp
|                   |   ExampleLibrary.sln
|                   |   ExampleLibrary.vcxproj
|                   |   ExampleLibrary.vcxproj.filters
|                   |   MyPluginLibrary.Build.cs
|                   |   MyPluginLibrary.tps
|                   |   
|                   +---ExampleLibrary
|                   |   \---ExampleLibrary.xcodeproj
|                   |           project.pbxproj
|                   |           
|                   +---ExampleLibrary.xcworkspace
|                   |       contents.xcworkspacedata
|                   |       
|                   +---Public
|                   |   \---MyPluginLibrary
|                   |           ExampleLibrary.h
|                   |           
|                   \---x64
|                       \---Release
|                               ExampleLibrary.dll
|                               ExampleLibrary.lib
|                               
+---Saved
+---Source

Thanks,

Matt

Found some links that might be useful. I’ll edit this message when I get a chance to try them. The first seems like what I’m looking for:

Discussion of the directory tree:

Starting from a blank project:

Has some diagrams of the library structure, but no directory tree:

Linux example:

Ok, I now understand the layout of the directory.

The files in Plugins\MyPlugin\Source\MyPlugin are the files that have the code that Unreal needs to load your plugin library. These are not your plugin itself. You may need to modify these files, but do not delete them.

The files in Plugins\MyPlugin\Source\ThirdParty\MyPluginLibrary may be your plugin library code. You have 3 options here.

  1. If you are going to write your own library and don’t have any code for it yet, you can put your C++ code here. You must compile your library from the ExampleLibrary.sln file, as your main C++ Unreal Solution will not build this library for you. I’m not sure I like option 1: I’d prefer to start with file names that are better than ExampleLibrary.*.
  2. If you already have your own code, you could copy your solution, project, and code files into this directory, and delete the ExampleLibrary.* files. Do not delete the MyPluginLibrary.*files. You still need to compile your code from the solution you use to replace ExampleLibrary.sln. You Unreal project will not compile your plugin library code.
  3. If you are using someone else’s library, or if you have your own code but don’t want to copy it over the ExampleLibrary files, then you can delete the ExampleLibrary.* files. Don’t delete the MyPluginLibrary.Build.cs file, though. If you pick this option, you’ll need to modify MyPluginLibrary.Build.cs such that it copies the library from its location outside your Unreal project into the appropriate Plugins\MyPlugin\Source\ThirdParty\MyPluginLibrary\$architecture directory. The first link in my first reply demonstrates copying the libraries for FFMPEG (built separately) into the $architecture directory.

Personally, I’m choosing option 3. I think it will be easier to handle version control if the files for the Unreal project and the files for the plugin library (the files that would replace the ExampleLibrary files) were in separate Git projects.

This definitely depends on your needs, however. If you are working with a team of developers, option 3 may not work for you: I don’t see how a team could use option 3 because there doesn’t seem to be a way for people to configure the location of the library files that need to be copied. If the directory is hard-coded (not configurable), the path to where you keep your library may not work for your teammate who may have the library in a different location. (Example: I have the code for MyPlugin cloned to /home/archer/MyPlugin. I have the Unreal project cloned to /home/archer/AmazingGame. My teammate has the code for MyPlugin cloned to /home/coworker/MyPlugin. If the MyPluginLibrary.Build.cs file way down inside AmazingGame copies the plugin library from /home/archer/MyPlugin, my coworker will be surprised when the changes he makes in /home/coworker/MyPlugin don’t show up when he loads the plugin from within AmazingGame.

That’s a high-level summary of what I learned from Wrapping a third party library using an Unreal Engine Plugin | Unrealcode.net .

One more note: I needed to add the third party plugin name (e.g., MyPlugin in the example above) to my Unreal Project’s Build.cs file.

	PublicDependencyModuleNames.AddRange(new string[] {
		"Core",
		"CoreUObject",
		"Engine",
		"InputCore",
		"EnhancedInput",
		"AIModule",
		"StateTreeModule",
		"GameplayStateTreeModule",
		"UMG",
		"Slate",
		"MyPlugin"
	});