Hello,
we have encountered a rather strange behavior when using property of type TMap<EEnum, value> that is located in the actor’s component. As described in the reproduction steps, adding a new item into the property results in an error message being displayed: Cannot add a new element to the map as all the enum values are already added
However, new value is added and after saving and reloading the level, the property holds the correct value.
We have also noticed, that this behavior does happen only when editing the property within the actor’s component. When the property is located within the actor, there is no error at all and adding multiple values correctly iterates over the enum items.
Another observation is, that error is only displayed when editing the property from actor’s component for actor placed in the level. When editing a property in the Blueprint editor, there is no error displayed and adding multiple values correctly iterates over the enum items.
Cheers,
Matej
[Attachment Removed]
Steps to Reproduce
- Create a simple UEnum, for example:
UENUM(BlueprintType)
enum class ETestEnum : uint8
{
AAA,
BBB,
CCC,
};
- Add property of TMap, that uses this enum as a key into actor compoment. For example:
UPROPERTY(EditAnywhere)
TMap<ETestEnum, int> TestMapProperty;
- Launch editor a add an instance of an actor with the component into the level
- Try adding a new item into the property (by clicking on the + icon)
- Observe the error message “Cannot add a new element to the map as all the enum values are already added”
[Attachment Removed]
Hi Matej,
Thank you for the report. I was able to repro this behavior on all versions from UE 5.4 up to a recent source version. Note that, in earlier versions, adding entries to an Enum-based map in the scenario you described would result in new entries always being initialized with the first Enum value (instead of the first unused one), triggering the “duplicate keys not allowed” warning after the first addition (and this in fact seems to still be happening for BP-defined Enums). It is possible that the current behavior is an unintended side effect of some change meant to address that. It might also be related to the fix that was implemented for UE-219729.
In any case, I am filing an internal bug report for this issue now, and I should get back to you soon with the tracking number for it. If I understand correctly, this is not blocking your work, correct?
Best regards,
Vitor
[Attachment Removed]
Hello Vitor,
Thanks for Your response. Yes, it appears that the issue is not blocking us in any way. It it changes and we find more problems (or information regarding this issue), I will report back.
Cheers,
Matej
[Attachment Removed]
Alright, here’s the tracking number for the bug report: UE-361674.
All the best,
Vitor
[Attachment Removed]