Rider for Unreal Engine, how to create a custom file template

Answered

Hello I'm trying to create a custom file template for unreal engine that allows me to create blueprint function libraries, I am intending on using the base UBlueprintFunctionLibrary class but it seems to be only showing up as a UObject(I used the UObject template as a base). What would I need to edit to have it working?

9 comments
Comment actions Permalink

Hello Oldsiren

When you open a project, Rider imports the existing file templates from Engine\Content\Editor\Templates and uses predefined settings when working with the default file templates. However, Rider's templating engine is not aware of base classes for custom/arbitrary templates. Considering this limitation, please replace the base class template variables with the expected values of those variables (for example, UBlueprintFunctionLibrary, instead of $PREFIXED_BASE_CLASS_NAME$). 

Let me know if this approach does not work for you.

1
Comment actions Permalink

Hello Kirill,

Thank you that worked! That clears it up where those macros are being generated... hopefully a future update exposes those template values in the editor to make it easier for customization. Again thank you!

0
Comment actions Permalink

You're welcome! Please feel free to contact us if you have any other questions.

Have a nice day!

0
Comment actions Permalink

Hello Kirill(or if another member of JetBrains' staff sees this),

I was making another template but this time it was a UWidget class and I wanted to have some functions already declared and defined in the header/source files for it. for example

in the header

// Copyright...

#pragma once

#include "CoreMinimal.h"
#include "Components/Widget.h"
#include "MyCoolWidget.generated.h"

/**
*
*/
UCLASS()
class MYCOOL_API UMyCoolWidget: public UWidget
{
GENERATED_BODY()
public:
UMyCoolWidget(const FObjectInitializer& ObjectInitializer);

protected:
// UWidget interface
virtual TSharedRef<SWidget> RebuildWidget() override;
#if WITH_EDITOR
virtual const FText GetPaletteCategory() override;
#endif
// ~UWidget interface

// UVisual interface
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
// ~UVisual interface

};

and in the source file

// Copyright...


#include "MyCoolWidget.h"

#define LOCTEXT_NAMESPACE "UMG"

UMyCoolWidget::UMyCoolWidget(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{

}

TSharedRef<SWidget> UMyCoolWidget::RebuildWidget()
{
return Super::RebuildWidget();
}

void UMyCoolWidget::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
}

#if WITH_EDITOR

const FText UMyCoolWidget::GetPaletteCategory()
{
return Super::GetPaletteCategory();
}

#endif

#undef LOCTEXT_NAMESPACE

but so far when I make the template it only does it for the header and the source file is empty with just the include path and copyright, where would I be able to modify the source file template if its possible for custom templates?

0
Comment actions Permalink

Hello Oldsiren,

Would you mind describing how you created a new template - from Rider's settings page or manually in the Templates engine directory? Currently, for the UE multi-file templates (.cpp/.h) to work, you'll need to create them in the engine directory and restart Rider, otherwise, Rider will not be able to detect the source template.

0
Comment actions Permalink

Hello Kirill,

Thanks for getting back to me, gotcha I was editing them in the settings page. Where would I find the Templates file within rider to be able to modify the multi-file templates? I am on a windows machine if that helps.

0
Comment actions Permalink

Oldsiren You can switch to the "File system" view in the Explorer tool window and find the Content\Editor\Templates directory in the Engine project. Here's an example:

You'll need to create/modify the templates in this directory and restart Rider for changes to take effect.

 

Please note that we are aware of the multi-file template issue, but I cannot give you an ETA at this time, and this is just a workaround.

1
Comment actions Permalink

Kirill Filin thank you so much! I really appreciate your help with answering my questions. I totally understand about the ETA everybody is busy haha at least its easy to modify and not too much of a nightmare

0
Comment actions Permalink

Happy to help! Feel free to reach out to us if you have any other questions about Rider or encounter any difficulties.

0

Please sign in to leave a comment.