Hello. I want to make a static helper library, which prints the text to the game screen. I tried this code but it gives error.
Helper.h:
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Helper.generated.h"
/**
*
*/
UCLASS()
class BETHEONE_API UHelper : public UObject
{
GENERATED_BODY()
public:
static void PrintToScreen(FString String);
};
Helper.cpp:
#include "Helper.h"
void PrintToScreeen(FString String)
{
if (GEngine) {
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::White, *String);
}
}
The error:
When I try to call the function like UHelper::PrintToScreen(TEXT(“Something”)); and first including like #include “Helper.h”, it gives two errors. First of all, it says identifier "GEngine" is undefined
, and second one is just a crash without any trace.
What is the problem? I am using the version 4.20.1.