Engine plugin to add a file to game package


I’m trying to find a way in which an engine plugin could add a file to the package directory of a game project that is using this plugin. The file must be outside the .pak file.

What options do I have?

I’ve been able to add a RuntimeDependency which is pathed in the form of “$(ProjectDir) + MyFile.Ext” with the type of StagedFileType.NonUFS, and that works, however, the pack will fail if this file does not exist, and I would like to make it optional.

I was thinking I could just check if the file exists before adding it as a runtime dependency, but inside the ModuleRules class I am not able to determine the actual project directory in order to check. Any way I can find out?

Hey RotemS! I though about this before aswell. A custom Program together with a post-build step in the plugin could potentially work. I’d be very interested aswell, so please do post the answer, if you find out!

A post-built step does sound like it could work. However, I’m not sure what variable I could use which indicates the output directory? How would I know where to copy my file to?

I guess you would have some configuration which would be stored with the DefaultEngine.ini and set from the Project Settings You can load that configuration in your custom program, too.

I ended up using the RuntimeDependency as written in the question body. To make sure the file always exists, I create it in a prebuild step defined in my .uplugin file if it’s not already there:

			"IF NOT EXIST \"$(ProjectDir)\\MyFile.ext\" (
			         type NUL > \"$(ProjectDir)\\MyFile.ext\"

Ugly, but works.