I have a HUD subclass called ARPGTestHUD, and it features a reticule in the center of the screen alongside what is supposed to be a minimap (it’s a render texture that shows the view from a camera positioned above the player character’s head, facing downwards).
RPGTestHUD.h features a forward class declaration:
class UTextureRenderTarget2D;
UCLASS()
class WEAPONESSENTIALS_API ARPGTestHUD : public AHUD
{
GENERATED_UCLASS_BODY()
...
/** Minimap asset pointer */
UTextureRenderTarget2D* MiniMapTex;
};
And it includes Engine/TextureRenderTarget2D.h in RPGTestHUD.cpp.
...
#include "Engine/Canvas.h"
#include "Engine/TextureRenderTarget2D.h"
#include "CanvasItem.h"
#include "RPGTestHUD.h"
ARPGTestHUD::ARPGTestHUD(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
...
// Set Minimap texture
static ConstructorHelpers::FObjectFinder<UTextureRenderTarget2D> MiniMapTexObj(TEXT("Texture2D'/Game/HUD/MapTarget.MapTarget'"));
MiniMapTex = MiniMapTexObj.Object;
}
void ARPGTestHUD::DrawHUD()
{
Super::DrawHUD();
...
// Draw minimap
FCanvasTileItem MiniMapTileItem(MiniMapDrawPosition, MiniMapTex->Resource, FLinearColor::White);
MiniMapTileItem.BlendMode = SE_BLEND_Translucent;
MiniMapTileItem.Size = FVector2D(256, 256);
Canvas->DrawItem( MiniMapTileItem );
}
Unfortunately, it fails to compile in Xcode on the following line:
FCanvasTileItem MiniMapTileItem(MiniMapDrawPosition, MiniMapTex->Resource, FLinearColor::White);
The error is “no member named 'Resource in ‘UTextureRenderTarget2D’”. This is possibly due to Engine/TextureRenderTarget2D.h claiming that UTextureRenderTarget (the superclass of UTextureRenderTarget2D) is an unknown class name. It’s a really bizarre error because my project is not a GitHub project. Am I missing any #includes in RPGTestHUD.cpp, or is there some other problem?