How to Change UE4 Class Templates

So have you created a C++ class in UE4 and it creates the class like this? Do you just hate the extra comments or spacing that the template has? Same. 🙁

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include “CoreMinimal.h” #include “GameFramework/Actor.h” #include “MyActor.generated.h”

UCLASS() class THINGGAME_API AMyActor : public AActor { GENERATED_BODY()

public: // Sets default values for this actor’s properties AMyActor();

protected: // Called when the game starts or when spawned virtual void BeginPlay() override;

public: // Called every frame virtual void Tick(float DeltaTime) override;

};

Well don't worry, you're in the right place to get it looking better.

Head over to your engine install and edit the appropriate file in D:\Program Files\Epic Games\UE_4.26\Engine\Content\Editor. I only edited Actor, ActorComponent, Character, Interface, and Pawn. Unfortunately, you can't do this for classes like PlayerState or GameMode as they're hardcoded in the GameProjectUtils.cpp(496). So instead you can just edit the UObjectClass.h.template and UObjectClass.cpp.template files. I wish the generation method was via file name instead of actual class type so we could just make a file called PlayerStateClass.h.template and PlayerStateClass.cpp.template and then it just generates the PlayerState based on it. 🤷‍♂️

My result is this.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include “CoreMinimal.h” #include “GameFramework/Actor.h”

#include “MyActor.generated.h”

/** * */ UCLASS() class THINGGAME_API AMyActor : public AActor { GENERATED_BODY()

public: AMyActor();

protected: virtual void BeginPlay() override; virtual void Tick(float DeltaTime) override;

virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

private: };

 

Download my template files here.

 

until next time