Daily Unreal Column #87 - Source code class templates
When you want to create new class in Unreal Engine you can pick a template you want to use. It is, however, very likely, that you want to delete or add something to that template. Here is how.
There are some changes that you might want to introduce to the class templates that already ship with the engine. Or, perhaps, you want to introduce your own. Either way, you can find all existing templates inside the Engine\Content\Editor\Templates
directory.
%COPYRIGHT_LINE%
#pragma once
#include "CoreMinimal.h"
%BASE_CLASS_INCLUDE_DIRECTIVE%
#include "%UNPREFIXED_CLASS_NAME%.generated.h"
UCLASS(%UCLASS_SPECIFIER_LIST%)
class %CLASS_MODULE_API_MACRO%%PREFIXED_CLASS_NAME% : public %PREFIXED_BASE_CLASS_NAME%
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
%PREFIXED_CLASS_NAME%();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
%CLASS_FUNCTION_DECLARATIONS%
%CLASS_PROPERTIES%
};
This is for example template file for a header file for the Actor class. I don’t know about you, but first thing I always do is delete all the comments and then move the Tick
function right under the constructor to get rid of the second public
namespace. Perhaps you might want to delete the tick function completely and modify the CPP file to disable ticking by default.
I highly recommend adjusting these templates to your project to improve the quality of life of your developers.