Thanks for the detailed explanation @Laurens!
Where do you put the pak file in order for it to be automatically picked up? Do you have to build your plugin from the game project (meaning you will have to ship your full game project to mod creators) or can you create it from a separate project?
This is what I got working yesterday, in case it helps anyone:
I have two Unreal projects, BaseGame and ModKit. BaseGame has custom code and assets; ModKit is completely empty except for an editor module (derived from SimpleUGCEditor) that adds buttons to the editor for creating and packaging mods.
Importantly, ModKit’s .uproject
file is actually called BaseGame.uproject
. This appears to be required to get BaseGame to pick up plugins packaged for ModKit later.
To create a new mod, I simply create a new plugin in the “Mods” directory of ModKit. I use the “Create UGC” button from SimpleUGCEditor to create the plugin, although as currently written, it adds AdditionalPluginDirectories": ["Mods"]
to the end of my ModKit’s .uproject
file which I have to remove to avoid errors about including the same plugin twice.
To package the mod, instead of using the “Package UGC” button from SimpleUGCEditor (since it requires building AutomationTool from source), I used this approach:
- Package the ModKit as a game itself, either using the “File > Package Project” menu, or creating a new ProjectLauncher configuration (see Tom Looman’s guide referenced above).
- Copy
Metadata
and AssetRegistry.bin
from ModKit\Saved\Cooked\WindowsNoEditor\BaseGame
to ModKit\Releases\<version name>\WindowsNoEditor
(this is in the UGCExample guide)
- Use Tom Looman’s technique (creating a DLC build configuration) to figure out the correct command line arguments to pass to
<UE>\Engine\Builds\BatchScripts\RunUAT.bat BuildCookRun
. (See “Command Line” at https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/Deployment/BuildOperations/_ for a discussion of using ProjectLauncher to figure out BuildCookR arguments.) In my case, the command that is working so far is:
.\RunUAT.bat BuildCookRun -project=path/to/ModKit/BaseGame.uproject -noP4 -nocompileeditor -targetplatform=Win64 -cook -pak -dlcname=MyFirstMod -DLCIncludeEngineContent -basedonreleaseversion="1.0.0" -compressed -stage -package -archive -archivedirectory=/Staging/ModKit/1.0.0 -clientconfig=Development -serverconfig=Development
I will be iterating on those arguments today to figure out which ones I really need/want.
This builds and packages my mod to /Staging/ModKit/1.0.0/WindowsNoEditor/BaseGame/Mods/MyFirstMod
. I built BaseGame separately to /Staging/BaseGame/1.0.0
, then copied the MyFirstMod
folder to /Staging/BaseGame/1.0.0/WindowsNoEditor/BaseGame/Mods
.
In my base game, I include the UGCRegistry
code from UGCExample to find all the mods and any maps they contain. Currently I iterate over all mods and maps and load the first map I find. This is working.
So with this technique it looks like I don’t need to share BaseGame with mod creators, as long as ModKit’s project is actually named BaseGame. If I named ModKit’s .uproject
file ModKit.uproject
, BaseGame will see the mod, but it doesn’t seem to load the map into the asset manager.
Here is the UGC Example for anyone who needs it (requires Epic Games GitHub membership—Unreal Engine 4 on GitHub - Unreal Engine). https://github.com/EpicGames/UGCExample/blob/release/Documentation/QuickStart.md
This is the code for finding all the mods: https://github.com/EpicGames/UGCExample/blob/58eaa3207c283a07227cd62da03f2ec4167c0705/Plugins/SimpleUGC/Source/SimpleUGC/Private/UGCRegistry.cpp#L16
And this is the code for finding all maps within a mod: https://github.com/EpicGames/UGCExample/blob/58eaa3207c283a07227cd62da03f2ec4167c0705/Plugins/SimpleUGC/Source/SimpleUGC/Private/UGCRegistry.cpp#L67
Hope this is helpful for someone!