Hello,
I am trying to attach a BP Enumeration asset to a custom c++ class in a way that will expose it within the editor.
However, I’m running into a lot of trouble. I’m able to attach the asset as a UEnum*. However, it doesn’t give me the dropdown of the elements like I wanted when I place the blueprint(from the c++ class) within the editor. It only gives me the UEnum object itself.
I’d like to use a BP Enumeration over a c++ one for ease of access. I don’t need to make any changes to it within the c++ code, I just need to editable within the editor. I also want to make it an array, but I’m assuming I just have to figure this out, then put it in a TArray<>.
The c++ class inherits from UStaticMeshComponent. For some reason, this doesn’t let me generate a blueprint from it, so a cannot at the Enumeration there.
Here is my c++ code. It’s very basic so far:
UGameBoard_Tile_SMC.h
#pragma once
#include "Components/StaticMeshComponent.h"
#include "GameBoard_Tile_SMC.generated.h"
UCLASS()
class STRATEGYGAMEV2_API UGameBoard_Tile_SMC : public UStaticMeshComponent
{
GENERATED_BODY()
public:
UGameBoard_Tile_SMC();
UPROPERTY(EditAnywhere, Category = "TileStates")
UEnum* TileStateEnumeration;
};
UGameBoard_Tile_SMC.cpp
#include "StrategyGameV2.h"
#include "GameBoard_Tile_SMC.h"
UGameBoard_Tile_SMC::UGameBoard_Tile_SMC()
{
static ConstructorHelpers::FObjectFinder<UEnum> BPGBCResource(TEXT("Enumeration'/Game/GameBoardAssets/Blueprints/EGameBoard_TileStates'"));
if (BPGBCResource.Object != NULL)
{
TileStateEnumeration = BPGBCResource.Object;
}
}
ExecutionCode within constructor of a custom class derived from AActor:
TileMesh = LoadObject<UStaticMesh>(NULL, TEXT("/Game/GameBoardAssets/Meshes/TileFloor"), NULL, LOAD_None, NULL);
UGameBoard_Tile_SMC* tile = CreateOptionalDefaultSubobject<UGameBoard_Tile_SMC>(TEXT("Gameboard_Test"));
tile->SetStaticMesh(TileMesh);
this->AddInstanceComponent(tile);
tilelist.Add(tile);
Result:
Desired:
If anyone can help, I would appreciate it. Again, I don’t have to use the actual enumerator within the c++. I plan I using it when I get into the blueprint development side of things.