Unable to find 'enum' with name | Can't use custom Enumuerator with TEnumAsByte<enum>

I’ve decided to use C++ (against my better judgement) to create a class for my data assets. Initially I thought I could use my pre-existing Enumerations I created in the editor but then realized I had to create an enum class from scratch to get it referenced cleanly in the header file. Unfortunately for me, like every time I use C++ in Unreal, it crashed while I was working on it and now refused to recompile or build until I fix the issues from vs, I’ve gotten all but one error down (the others were simple “.generated.h” files not showing up but I fixed those by just removing it from the enum file). Now my issue is that it fails to build because: “Unable to find ‘enum’ with name ‘EItemID’”, I’ve tried just about everything from changing the file class and type- to editing the parameters to see what works. I still can’t seem to get it or find anyone whose faced the same problem and posted a solution. namespace doesn’t seem to do anything or I’m doing it wrong, and adding ‘enum class EItemID : uint8’ doesn’t seem to work either. Any help? Are enums really this tricky?

#pragma once

#include "ItemID.h"

UNEUM(BlueprintType)
enum ItemID {
	ART_LITERATURE	UMETA(DisplayName = "Artifact_Literature"),
	ART_PAINTING	UMETA(DisplayName = "Artifact_Painting"),
	ART_SCRIPTURE	UMETA(DisplayName = "Artifact_Scripture"),
	ART_SCULPTURE	UMETA(DisplayName = "Artifact_Sculpture"),
	ART_ARROW		UMETA(DisplayName = "Ammunition_Arrow"),
	ART_BULLET		UMETA(DisplayName = "Ammunition_Bullet")
};

my Data asset header file:

#pragma once

#include "CoreMinimal.h"
#include "ItemID.h"
#include "Containers/EnumAsByte.h"
#include "Engine/DataAsset.h"
#include "Engine/StaticMesh.h"
#include "Engine/SkeletalMesh.h"
#include "Materials/MaterialInstance.h"
#include "ItemDataAsset.generated.h"

UCLASS()
class DARRM_API UItemDataAsset : public UPrimaryDataAsset {
	GENERATED_BODY()

public:

	// Item designation used instead of tags to identify properties.
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default")
		TEnumAsByte<EItemID> Designation;

	/**
	 * [0] Name (Singular)
	 * [1] Name (Pluaral)
	 * [2] Name (Adjective)
	 * [3] Description (Short)
	 * [4] Description (Long)
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default")
		TArray<FString> Information;

	/**
	 * [0] Singular (Default)
	 * [1] Singular (Broken)
	 * [2] Stack (Size 10%)
	 * [3] Stack (Size 25%)
	 * [4] Stack (Size 50%)
	 * [5] Stack (Size 75%)
	 * [6] Stack (Size Full)
	 * [7[ Stack (Broken)
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default")
		TArray<UStaticMesh*> Model;

	/** Skeletal mesh used for the item when equipped if there is one.. */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default")
		TArray<USkeletalMesh*> Mesh;

	/**
	 * [0] Default Texture
	 * [1] Wet/InWater
	 * [2] Burning/OnFire
	 * [3] Burned/Oxidized
	 * [4] Old/Rusted/Spoiled
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default", meta = (MultiLine = "true"))
		TArray<UMaterialInterface*> Material;

	/**
	 * [0] Value
	 * [1] Weight (Kilograms)
	 * [2] Strength (Health)
	 * [3] Stacksize (Max)
	 * [4] Length (Centimeters)
	 * [5] Cut/Soft (Damage/Armor)
	 * [6] Blunt/Hard (Damage/Armor)
	 * [7] Spoilage/Oxidation (Time)
	 * [8] Fermentation/Rusting (Rate)
	 * [9] Burning/Smelting (Time)
	 * [10] Hunger (Amount)
	 * [11] Thirst (Amount)
	 * [12] Freezing/Insulating (Temp)
	 * [13] Boiling/Smelting (Temp)
	 * [14] Cutting/Chisseling (Hardness)
	 * [15] Flammability (Chance)
	 * [16] Explosiveness (Power)
	 * [17] Beauty/Ugliness (-100/100)
	 * [18] Tastiness/Grossness (-100/100)
	 * [19] Aroma/Smelliness (-100/100)
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default", meta = (MultiLine = "true"))
		TArray<double> Values;

	/**
	 * [0] WeaponSlot_0
	 * [1] WeaponSlot_1
	 * [2] ArmorSlot_Head
	 * [3] ArmorSlot_Face
	 * [4] ArmorSlot_Back
	 * [5] ArmorSlot_Chest
	 * [6] ArmorSlot_Shirt
	 * [7] ArmorSlot_Utility
	 * [8] ArmorSlot_Pants
	 * [9] ArmorSlot_Shoes
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default")
		TArray<bool> Equipment;

	/** Gameplay tags this item has. */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default", SaveGame)
		TArray<FGameplayTag> Properties;

	/**
	 * [0] Primary Color
	 * [1] Secondary Color
	 */
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Default", SaveGame)
		TArray<FColor> Colors;
};

The correct way would be like this (note you have a typo in UENUM)
You also need to prefix Enums with an E

UENUM(BlueprintType)
enum class EItemID : uint8
{
	ART_LITERATURE	UMETA(DisplayName = "Artifact_Literature"),
	ART_PAINTING	UMETA(DisplayName = "Artifact_Painting"),
	ART_SCRIPTURE	UMETA(DisplayName = "Artifact_Scripture"),
	ART_SCULPTURE	UMETA(DisplayName = "Artifact_Sculpture"),
	ART_ARROW		UMETA(DisplayName = "Ammunition_Arrow"),
	ART_BULLET		UMETA(DisplayName = "Ammunition_Bullet")
};

And you should no longer use TEnumAsByte but simply the type

EItemID Designation;

Apologies for the confusion I should’ve mentioned exactly what I’ve tried already. This doesn’t work because it gives me another error resulting in:

Unable to find ‘class’, ‘delegate’, ‘enum’, or ‘struct’ with name ‘EItemID’

Sorry for the late reply and any confusion, I’m just stumped on what I need to do here.

Edit: Turns out I’m dyslexic here since I actually did mispell UENUM.

The enum should be declared in ItemID.h

I don’t know what this file is, but it probably shouldn’t exist

image

All of this should be in ItemID.h (except the include obviously)
also it should be called EItemID

This is ItemID.h itself. Changing the ItemID to EItemID only gets another error message of it not recognizing it as a class or struct or enum in the file I’m trying to reference it in.

Ok then you also need to #include "ItemID.generated.h" in ItemID.h

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.