Summary
I have created these enums:
CommonENUMS.h
UENUM(BlueprintType)
enum class EActorType : uint8
{
//Pawn Types
Villager UMETA(DisplayName =“Villager”),
Swordman UMETA(DisplayName =“Swordman”),
Knight UMETA(DisplayName =“Knight”),
Archer UMETA(DisplayName =“Archer”),
//Building Types
House UMETA(DisplayName ="House"),
};
BaseBuilding.h
UPROPERTY(EditAnywhere,BlueprintReadOnly, Category=Building, meta=(AllowPrivateAccess=true))
EActorType ActorType = EActorType::House;
BaseBuilding.cpp
void ACLMBaseBuilding::RevertBuildingPlacementCost()
{
FString ActorTypeStr = UEnum::GetValueAsString(EActorType::House);
//FString ActorTypeStr = UEnum::GetValueAsString(ActorType);
//FString ActorTypeStr = “House”;
FString CleanNameStr = “House”;
//ActorTypeStr.Split(TEXT(“::”),nullptr,&CleanNameStr);
FActorBuildCost* BuildCost = DTBuildCost->FindRow(FName(CleanNameStr),TEXT(“”));
if (BuildCost)
{
ATopDownPlayerState* PlayerState = Cast<ATopDownPlayerState>(GetWorld()->GetFirstPlayerController()->PlayerState);
UE_LOG(LogTemp, Warning, TEXT("RevertBuildingPlacementCost for %s"), *ActorTypeStr);
PlayerState->RevertBuildCost(BuildCost->BuildCost);
}
}
On this line I get error:
FString ActorTypeStr = UEnum::GetValueAsString(EActorType::House);
[1/1] Compile [x64] CLMBaseBuilding.cpp
C:\Program Files\Epic Games\UE_5.8\Engine\Source\Runtime\CoreUObject\Public\UObject\Class.h(3338,22): error C2280: 'UEnum StaticEnum(void)': attempting to reference a deleted function
with
[
EnumType=EActorType
]
UEnum EnumClass = StaticEnum();
It points to Class.h
template
inline static FName GetValueAsName(const EnumType EnumeratorValue)
{
// For the C++ enum.
static_assert(TIsEnum::Value, “Should only call this with enum types”);
UEnum* EnumClass = StaticEnum();
check(EnumClass != nullptr);
return EnumClass->GetNameByValue((int64)EnumeratorValue);
}
Cant figure it out, could someone help with this issue?
What Type of Bug are you experiencing?
Editor
Steps to Reproduce
Call enum GetValueAsName on enum
Expected Result
Return string of Enum
Observed Result
Gives error, that enum no longer exist
Affects Versions
5.8
Platform(s)
Windows