I can’t seem to wrap my head around this problem in visual studio.
pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "MainHUD.generated.h"
class UChatMenu;
UCLASS()
class MYPROJECT_API AMainHUD : public AHUD
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = "Widgets")
TSubclassOf<UChatMenu> ChatWidgetClass;
bool isChatVisible;
AMainHUD();
void DisplayChat();
void HideChat();
protected:
UPROPERTY()
UChatMenu* ChatMenuWidget;
virtual void BeginPlay() override;
};
#include "UserInterfaces/MainHUD.h"
#include "UserInterfaces/ChatWidget.h"
AMainHUD::AMainHUD()
{
}
void AMainHUD::BeginPlay()
{
Super::BeginPlay();
if (ChatWidgetClass) {
UChatMenu* ChatMenuWidget = CreateWidget<UChatMenu>(GetWorld(), ChatWidgetClass, FName("ChatWidget"));
ChatMenuWidget->AddToViewport(64);
ChatMenuWidget->SetVisibility(ESlateVisibility::Collapsed);
}
}
The problem arises on this line:
UChatMenu* ChatMenuWidget = CreateWidget<UChatMenu>(GetWorld(), ChatWidgetClass, FName("ChatWidget"));
I don’t want to use staticclass since I’ve heard that it can cause some problems and stuff, but even putting it there seemed to not solve it.
No instance of function template "CreateWidget" matches the argument list:
argument types are (uworld*, tsubclassof<uchatmenu>, fname)
I think the problem is at the second argument, but I don’t know how to solve this.
Help is appreciated.