How to get a texture to a UTexture variable?

Hello and good afternoon everybody,

I have been messing with unreal for a while already, and I am trying to make a simple HUD for my game, which will use textures, I am using a class of my own which is inherits from AHUD, no changes in constructors or destructors, just custom methods to draw the heads up display, however, I am still struggling on on how I can get a texture and draw it to the screen using the method “DrawTextureSimple”, I succeeded in doing so by setting the texture in blueprints through a blueprintable method I created in C++ (method setTexture), however I cannot yet understand how to do the same in pure C++ (trying through the method setTextureC)…

Can anyone explain to me how to do it?

*I am a noob…TT__TT

Thanks for the attention,



#pragma once

#include "GameFramework/HUD.h"
#include "DTPlayerState.h"

#include "DTHUD.generated.h"


	UTexture* texture;

	UFUNCTION(BlueprintCallable, Category = "DT HUD")
	ADTPlayerState* GetPlayerState();

	UFUNCTION(BlueprintCallable, Category = "DT HUD")
	void SetPlayerState(ADTPlayerState* newPlayerState);

	UFUNCTION(BlueprintCallable, Category = "DT HUD")
	UTexture* GetTexture();

	UFUNCTION(BlueprintCallable, Category = "DT HUD")
	void SetTexture(UTexture* newTexture);

	UFUNCTION(BlueprintCallable, Category = "DT HUD")
	void SetTextureC();

	void DrawHUD();

	ADTPlayerState* dTPlayerState;


-FILE “DTHUD.cpp”:

#include "ActionSystem.h"
#include "DTHUD.h"

void ADTHUD::DrawHUD(){
	if (dTPlayerState){
		DrawTextureSimple(texture, 0, 0, 1, false);

void ADTHUD::SetPlayerState(ADTPlayerState* newPlayerState){
	dTPlayerState = newPlayerState;

ADTPlayerState* ADTHUD::GetPlayerState(){
	return dTPlayerState;

void ADTHUD::SetTexture(UTexture* newTexture){
	texture = newTexture;

UTexture* ADTHUD::GetTexture(){
	return texture;

void ADTHUD::SetTextureC(){

	static ConstructorHelpers::FObjectFinder<UTexture2D> MyObj(TEXT("/Game/ThirdPerson/test"));
	texture = MyObj.Object;

Hello, kitblackheart

You can use AHUD::DrawTexture function:

UFUNCTION(BlueprintCallable, Category=HUD, Meta=(AdvancedDisplay="9"))
void DrawTexture
    UTexture * Texture,
    float ScreenX,
    float ScreenY,
    float ScreenW,
    float ScreenH,
    float TextureU,
    float TextureV,
    float TextureUWidth,
    float TextureVHeight,
    FLinearColor TintColor,
    EBlendMode BlendMode,
    float Scale,
    bool bScalePosition,
    float Rotation,
    FVector2D RotPivot

Please also note that the line

static ConstructorHelpers::FObjectFinder<UTexture2D> MyObj(TEXT("/Game/ThirdPerson/test"));

should be placed in HUD’s constructor.

If you like to learn more about AHUD::DrawTexture function, please go here:

Hope this helped!

Have a great day!

Thank you very much! ^-^ it works just fine!