Rider for Unreal Engine custom file templates

Hello there,

I am hoping to take advantage of Rider's file templates with Unreal but can't seem to get past these final two hurdles.

  1. I can't figure out where the macros $BASE_CLASS_INCLUDE_DIRECTIVES$ and $PREFIXED_BASE_CLASS_NAME$ are being generated. For this file template, I want to use a custom base class.
  2. I can't figure out where the .cpp file generation happens. When creating my new class, the .cpp file only has %MY_HEADER_INCLUDE_DIRECTIVE% in it.

I have a feeling this ties into Unreal's templates found in Engine\Content\Editor\Templates but can't seem to figure out the link between Rider and Unreal.

Any help would be greatly appreciated!

0
7 comments

Hello Jeremymccarty,

Apologies for the extremely late reply.

Currently, the file generation for Unreal file templates is handled entirely by Rider, but is somewhat limited - you can only edit the header template in multi-file (.cpp / .h) templates in Rider and you can't specify a custom base class for a custom template.

To add and edit a .cpp template that is used along with your .h template, you can create a template pair (.cpp.template and .h.template) manually in the Engine\Content\Editor\Templates. Then reopen your project in Rider to import the template, find the new template in Rider and tick the Add to "New..." menu checkbox in template properties.

When you open a project, Rider imports the existing file templates from Engine\Content\Editor\Templates and uses predefined settings when working with file templates, Rider's templating engine is not aware of custom base classes that might exist in the project. Considering this limitation, you can write the base class name and it's include directive in the template explicitly to avoid macros (e.g. #include "Foo.h", instead of $BASE_CLASS_INCLUDE_DIRECTIVE$). 

Please let me know if it helps.

0

Hello Kirill Filin, I've tried a couple of time your solution, by adding new template files (.h / .cpp) in the Engine\Content\Editor\Templates, but I can't see them in my settings after relaunching Rider, is it a known issue?

0

Ok, maybe it's my fault, before finding the right solution, I've tried to add a new entry in the template settings, found out that it didn't generated the .cpp file, and then tried your solution, and remove the old one (with the same name) from the settings, so maybe something is corrupted, because if I add a new fresh file template with a random name, I can see it!

Is there a way to cleanup my cached settings for this?

Thanks!

0

Hello Gleplang,

To make sure we are on the same page regarding this issue, would you mind confirming if the steps below accurately describe what happened before you noticed the problem:

1. You tried to create a new template using Rider UI

2. When you noticed that the template does not work as you expect, you created a new template in the Engine\Content\Editor\Templates directory (I'm assuming, the new template had the same name)

3. You deleted the template record in Rider but the new template from the UE directory never showed up in Rider

0

Hello Kirill,

Yes, that's exactly it!

0

Hi Gleplang,

Thanks for the confirmation. You can restore the template by clearing the "hidden" status from the template - Rider does not remove UE templates imported from the Engine, it just hides the template when you delete it.

 

You'll need to edit the Rider's DotSettings file corresponding to the layer you saved the template to (if you never saved settings to 'Solution personal' or 'Solution team-shared', just refer to the global settings):

  • Global settings (GlobalSettingsStorage.DotSettings) can be found by opening the directory listed under Help -> Diagnostic tools -> Special Files and Folders -> R# Global Settings (you can open the directory from the context menu)
  • Team-shared settings (<ProjectName>.DotSettings) and Personal settings (<ProjectName>.DotSettings.user) are located in your project directory

Before proceeding, please backup the DotSettings file.

 

Look for the record(s) that look like this:

 <s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=<ID>/@KeyIndexDefined">False</s:Boolean>

and remove the record from the DotSettings file. Rider will refresh the template list and show the deleted records the next time you open Settings | Editor | File Templates | Unreal Engine.

Let me know if you encounter any issues or if anything is unclear.

0

Was looking for this for quite some time,
thanks soooo much.

0

Please sign in to leave a comment.