Hey guys! I have a problem with UActorComponent PostEditChangeProperty inside a actor bp. Even though the pattern matching works as expected, the elements are not saved.
I found that the value of this is TRASH_CourageGroupSelectorComponent in postedit change. This is obviously not good.
// h
USTRUCT(BlueprintType)
struct FCourageSelectionGroup
{
GENERATED_BODY()
UPROPERTY(EditAnywhere)
FString Pattern;
UPROPERTY(EditAnywhere)
TArray<USceneComponent*> Components;
};
UCLASS(meta = (BlueprintSpawnableComponent))
class UCourageGroupSelectorComponent : public UActorComponent
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
TArray<FCourageSelectionGroup> Groups;
...
}
void UCourageGroupSelectorComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& Event)
{
Super::PostEditChangeChainProperty(Event);
if (!GetOwner()) return;
const FName memberPropertyName = (Event.MemberProperty != NULL) ? Event.MemberProperty->GetFName() : NAME_None;
if (memberPropertyName == GET_MEMBER_NAME_CHECKED(FCourageSelectionGroup, Pattern))
{
for (auto& group : Groups)
{
group.Components.Empty();
if (group.Pattern != "")
{
TArray<USceneComponent*> candidates;
GetOwner()->GetComponents(candidates, false);
TArray<FString> patterns;
group.Pattern.ParseIntoArray(patterns, TEXT(";"), true);
for (auto& pattern : patterns)
{
auto globRegex = glob::compile_pattern(TCHAR_TO_UTF8(*pattern));
for (auto& comp : candidates)
{
if (!comp) continue;
if (std::regex_match(TCHAR_TO_UTF8(*comp->GetName()), globRegex))
{
group.Components.Add(comp);
}
}
}
}
}
}