This might not be exactly what you want but you can create static arrays like this:
UENUM(BlueprintType)
namespace EObjective
{
enum Type
{
// Numeric
CaptureReactor = 0 UMETA(DisplayName = "Capture Reactor"),
CaptureFlag UMETA(DisplayName = "Capture Flag"),
PickUpReactor UMETA(DisplayName = "Pick Up Reactor"),
PickUpFlag UMETA(DisplayName = "Pick Up Flag"),
// This must always be at the end
Max UMETA(DisplayName = "Invalid")
};
}
Then:
UPROPERTY(EditDefaultsOnly, Category = Rewards)
int32 ObjectiveRewards[EObjective::Max];
The only drawback I know is that you can’t expose the static array into BluePrints. But you can make a function like:
UFUNCTION(BlueprintCallable, Category = Rewards)
int32 YourClass::GetObjectiveReward(EObjective::Type inObjectiveType) const
{
return ObjectiveRewards[inObjectiveType];
}
The great thing about this way is that the Editor automatically shows the static array in a very readable way. Instead of a typical TArray where it would show
ObjectiveRewards
0: 40
1: 250
2: 400
3: 70
it shows the enum name + value:
ObjectiveRewards
CaptureReactor: 40
CaptureFlag : 250
PickUpReactor: 400
PickUpFlag: 70
You can iterate through the array:
for(int32 i = 0; i < EObjective::Type::Max; ++i)
{
UE_LOG(LogTemp, Log, TEXT("Array value: %d"), ObjectiveRewards[i]);
}