Hello again,
since 4.14 added support for TMap in editor I wanted to check it out. Here’s a list on how to reproduce the bug I have found, and some screenshots for quick reference.
-
Create New Project - Basic Code
-
Create New C++ Class - based on Actor (MyActor)
-
Create New C++ Class - based on ActorComponent (MyActorComponent)
-
Change code in MyActorComponent.h to:
USTRUCT(BlueprintType)
struct FMyStruct
{
GENERATED_BODY();UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test") float MyFloat;
};
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()public:
UMyActorComponent();UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test") TMap<uint8, FMyStruct> MyMap;
};
-
Add following lines to MyActor.h
UPROPERTY(Category = “Test”, VisibleAnywhere, Instanced, BlueprintReadOnly)
class UMyActorComponent* MyComponent; -
Change constructor in MyActor.cpp to:
AMyActor::AMyActor() : MyComponent(CreateDefaultSubobject(“MyComponent”))
{
PrimaryActorTick.bCanEverTick = true;
} -
Create Actor blueprint based on MyActor and check MyMap in MyComponent .
-
For a workaround, go back to MyActorComponent.h and add the following:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Test”)
TArray MyArray; -
Now TMap value can be changed from editor
Conclusion:
UStructs used as Values in TMaps used in ActorComponents inherited from C++ are not editable in editor, unless a TArray is added in the same C++ class. ActorComponents added from editor does not have this issue.