#include "Grid.generated.h"
USTRUCT(BlueprintType)
struct FGrid
{
GENERATED BODY()
FORCELINE FGrid();
explicit FORCEINLINE FGrid(int32 Value);
explicit FORCE INLINE FGrid (In32 X, Int32 Y);
//... add properties here
//... No UFUNCTIONS allowed but can use non-blueprintable functions
};
- UENUM Specifiers - Docs
UENUM(BlueprintType) enum class Foo : Uint8
{
None = 0 UMETA(DisplayName = "None")...
}
-
UPROPERTY Specifiers - Docs
UPROPERTY(VisibleAnywhere, Category = "Foo")
UPROPERTY(BlueprintReadOnly, Category = "Foo")
UPROPERTY(BlueprintReadWrite, Category = "Foo")
- Access Display Name of UENUM in Unreal:
UEnum::GetValueAsString(BuildingName);
- Use
TObjectPtr<ClassName>
intead of raw*
pointers for UPROPERTIES - Initialize FStrings with
FString Name = TEXT("This is a a string");
to ensure platform specific encoding - Use
check(pointer)
if you want the game to stop and assert on a null pointer (if that pointer is NOT supposed to be null). Otherwise a non-breaking way is to useif (IsValid(pointer)){//... do something}
- Docs
- Forward declare in the
.h
and include in the.cpp
to speed up compile times and limit cross reference errors - Initialize variables using the initilazation methode so use
int32 X{5};
instead ofint32 X = 5;
- Use bitfields for booleans
uint8 bIsFoo:1
if there are lots of booleans in a class/struct but then you cannot initialize without c++ 20 (not supported in Unreal)
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Yellow, TEXT("Write simple message here"));
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Yellow, FString::Printf(TEXT("Write message with vars: %d"), IntegerVar));
UE_LOG(LogTemp, Warning, TEXT("Text: %s"), *(ID.ToString()));