Hello, i m on UE5.1 and try to get the OverheadWidget workung.
VS2022 tells me, that OnLevelRemovedFromWorld is not a member of UUserWidget.
what can i do?
OverheadWidget.cpp
#include "Components/TextBlock.h"
void UOverheadWidget::SetDisplayText(FString TextToDisplay)
{
if (DisplayText)
{
DisplayText->SetText(FText::FromString(TextToDisplay));
}
}
void UOverheadWidget::ShowPlayerNetRole(APawn* InPawn)
{
ENetRole RemoteRole = InPawn->GetRemoteRole();
FString Role;
switch (RemoteRole)
{
case ENetRole::ROLE_Authority:
Role = FString("Authority");
break;
case ENetRole::ROLE_AutonomousProxy:
Role = FString("Autonomous Proxy");
break;
case ENetRole::ROLE_SimulatedProxy:
Role = FString("Simulated Proxy");
break;
case ENetRole::ROLE_None:
Role = FString("None");
break;
}
FString LocalRoleString = FString::Printf(TEXT("Remote Role: %s"), *Role);
SetDisplayText(LocalRoleString);
}
void UOverheadWidget::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld)
{
RemoveFromParent();
Super::OnLevelRemovedFromWorld(InLevel, InWorld);
}```
OverheadWidget.h
```#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "OverheadWidget.generated.h"
/**
*
*/
UCLASS()
class BLASTERNEW_API UOverheadWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(meta = (BindWidget))
class UTextBlock* DisplayText;
void SetDisplayText(FString TextToDisplay);
UFUNCTION(BlueprintCallable)
void ShowPlayerNetRole(APawn* InPawn);
protected:
virtual void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld) override; //Override or is final okay too?
};