Get Click Event When Clicking On AHUD::DrawTextureSimple Texture On Screen

Do I have to use hitboxes here (aka layer a hitbox over the texture on screen) or does the Texture Simple have the ability to get a click event?

Thanks!

You will need to place a hitbox if you want to receive clicks. None of the Draw elements provide them implicitly.

Thank you, Marc. What I’m doing now is putting down a simple texture then taking it’s position info and trying to put a hitbox over top of it. Does this look about right?


void AInventoryHUD::DrawInventoryItem(int32 Offset, UTexture* Thumbnail)
{

	float XCoord = (float)Offset * 100;

	float ThumbX = XCoord;
	float ThumbY = 1.f;

	float ThumbWidth = Thumbnail->GetSurfaceWidth();
	float ThumbHeight = Thumbnail->GetSurfaceHeight();

	AHUD::DrawTextureSimple(Thumbnail, ThumbX, ThumbY);

	FVector2D HBPosition;
	HBPosition.X = ThumbX;
	HBPosition.Y = ThumbY;
	FVector2D HBSize;
	HBSize.X = ThumbWidth;
	HBSize.Y = ThumbHeight;
	FName HBName = FName(TEXT("HB"));
	AHUD::AddHitBox(HBPosition, HBSize, HBName, false);

}

It compiles and plays, but since the hitbox is invisible, I don’t know if it’s actually showing.

Edit:

Actually, per an old answer of yours at how to show hitbox size in game? - Community & Industry Discussion - Unreal Engine Forums, I was able to turn on hitbox debugging and this does seem to be working. Is this the correct workflow?

Thanks!

That does look correct.

For debugging, you should be able to type “showdebug hitbox” on the console to visualize where the hitboxes are.