Create a custom template package in Unreal



After doing a lot of research on the internet to find out how to create a custom package on Unreal, I wasn't able to find anything related to the subject so i decided to write this article in order to help those who are interested in adding their templates or samples as a pack.


A package is a set of content that you can add to any project you want, it’s like migrating your content from one project to another, but instead of doing the whole loop, you can just select it from a collection of packages and add it to any project with a few clicks.


Create your template


Your pack can be either a project template or a content template.

A project template gives the foundation for a specific type of project like the Third Person or 2D Slider Scroller.



And a content template is like the Starter contents, a set of content that you can add to any project



For this tutorial we will create a custom template. Unreal gives us a base template from which we can build our own, all we need to do is to copy paste that template and add on top of it our custom feature. It can be either a code based or a Blueprint template



All i have done is copy paste the TP_BlankBP, add some content to it and updated the config file TemplateDefs.ini to match the information related to my new template



At this stage on starting a new project, the template will be listed among the other templates. We are now able to start a new project based on that



But how about adding it to an existing project ? As for now, when we add a new feature to our project, our custom package will not be listed amongst them.

So here’s the steps to make our template part of the packages that Unreal propose


Note : that the following steps works only with the source code and upon building a custom version of the engine


Create your custom package


To be recognized as a package, we need to create a .upak file from the template. It’s a manual process. We need to use the UnrealPack tool to bundle up our files.

There are two way to achieve that, we can directly create it by directory

This command will gather up every file in the directory, we first specify where to export our .upak and then the directory from which it will be exported.

Executing the command will generated a .upak that will be saved under FeaturePacks folder



Or we can do the same but instead of indicating the directory we indicate a file that contains the specified data (wildcards allowed) we want to gather up and store in the .upak and that’s the recommended approach

The contents.txt will look something similar to that

../../../Templates/TP_CustomTemplateBP/manifest.json
../../../Templates/TP_CustomTemplateBP/Config/config.ini
../../../Templates/TP_CustomTemplateBP/Content/*.*
../../../Templates/TP_CustomTemplateBP/Media/TP_CustomTemplateBP.png
../../../Templates/TP_CustomTemplateBP/Media/TP_CustomTemplateBP_Preview.png

Pathing is always fun, may take a few tries to get it all set up right.


Setting up the EngineFilter


To make the created template part of the building process we need to update the

InstalledEngineFIlters.xml and add our template part of the list that will be packed

 <!-- List of project to build Feature packs -->
 <Property Name="ProjectsToFeaturePack">
  TP_TwinStick
  TP_TwinStickBP
  TP_VehicleAdvBP
  TP_VehicleBP
  TP_VirtualRealityBP
  TP_CollaborativeBP
  TP_CustomTemplateBP
 </Property>

And also define it in the editor filter

  <!-- Define Editor Filters -->
 <Property Name="CopyEditorFilter">
  <!-- Templates -->
  Templates/TemplateCategories.ini
  Templates/Media/...
  Templates/TP_Blank/...
  Templates/TP_BlankBP/...
  Templates/TP_FirstPerson/...
  Templates/TP_FirstPersonBP/...
  Templates/TP_Flying/...
  Templates/TP_FlyingBP/...
  Templates/TP_Rolling/...
  Templates/TP_RollingBP/...
 
  <!-- Custom Templates -->
  Templates/TP_CustomTemplateBP/...

Once all those steps completed, when starting any project with the engine we’ve just built, the template will appear among the packages we can add to any project.