In my HUD base class I have a TArray of fonts.
The TArray element is a structure:
/**
* @brief This structure contains information about the fonts used to display information.
*
*/
USTRUCT()
struct FKFontStruct
{
GENERATED_USTRUCT_BODY()
/**
<summary>The font</summary>
*/
UPROPERTY(EditDefaultsOnly, Category = Attributes)
UFont* HUDFont;
/**
<summary>The font scale</summary>
*/
UPROPERTY(EditDefaultsOnly, Category = Attributes)
float HUDFontScale;
/**
<summary>The font color</summary>
*/
UPROPERTY(EditDefaultsOnly, Category = Attributes)
FColor HUDFontColor;
/**
<summary>The font type</summary>
*/
UPROPERTY(VisibleAnywhere, Category = Attributes)
EKFontTypeEnum HUDFontType;
/** defaults */
FKFontStruct()
{
HUDFont = NULL;
HUDFontScale = 1.0f;
HUDFontColor = FColor::Black;
HUDFontType = EKFontTypeEnum::KFT_Max;
}
};
The number of elements is based on the EKFontTypeEnum::KFT_Max
UENUM(BlueprintType) //"BlueprintType" is essential to include
enum class EKFontTypeEnum : uint8
{
KFT_General UMETA(DisplayName = "General"),
KFT_Debug UMETA(DisplayName = "Debug"),
KFT_MessageTitle UMETA(DisplayName = "MessageTitle"),
KFT_MessageText UMETA(DisplayName = "MessageText"),
KFT_InfoMessage UMETA(DisplayName = "InfoMessage"),
KFT_WarningMessage UMETA(DisplayName = "WarningMessage"),
KFT_CriticalMessage UMETA(DisplayName = "CriticalMessage"),
KFT_Normal UMETA(DisplayName = "Normal"),
KFT_Big UMETA(DisplayName = "Big"),
KFT_EnemyName UMETA(DisplayName = "EnemyName"),
KFT_Max UMETA(Hidden)
};
The TArray initialization occurred in PostInitializeComponents().
I sets the number of array’s elements.
void AKHUD::PostInitializeComponents()
{
Super::PostInitializeComponents();
// Sets the number of fonts
HUDFonts.SetNum((int32)EKFontTypeEnum::KFT_Max);
// and its type
for (auto idx = 0; idx < (int32)EKFontTypeEnum::KFT_Max; ++idx)
{
HUDFonts[idx].HUDFontType = (EKFontTypeEnum)idx;
}
}
If I had new fonts in EKFontTypeEnum, unfortunately the number of elements is not reflected in the property window.
If I had 4 font’s element and add 4 new, I’m still have 4 elements.
If I add 4 elements directly from the property window, when I relaunch the editor, all new 4 elements have KFT_Max as a font type.
It does not change its type even if the AKHUD::PostInitializeComponents() function is called and the loop executed correctly.
Is there another way to initialize a TArray and be reflected within the property window ?
Dominique