Non-instanced object ref properties are incorrectly being skipped at property initialization time when Blueprint class instances are spawned with the fast property initialization path enabled.
This results in a subobject instance that's unique per Blueprint class instance, so it behaves as if it were instanced. It should instead be referencing the subobject instance from the default data (parent CDO), in order to match what happens when the fast path cannot be taken (e.g. when spawning child actor components).
#pragma once #include "CoreMinimal.h" #include "UObject/NoExportTypes.h" #include "MySubobjectType.generated.h" /** * */ UCLASS(BlueprintType) // ADD 'BlueprintType' class UE_191334_API UMySubobjectType : public UObject { GENERATED_BODY() };
#pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "MySubobjectType.h" // ADD THIS INCLUDE #include "MyTestActor.generated.h" UCLASS() class UE_191334_API AMyTestActor : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AMyTestActor(); // ADD THIS PROPERTY UPROPERTY(EditAnywhere, BlueprintReadWrite) TObjectPtr<UMySubobjectType> MySubobjectInstance; protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; };
// Sets default values AMyTestActor::AMyTestActor() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; // ADD THIS LINE MySubobjectInstance = CreateDefaultSubobject<UMySubobjectType>("MySubobject"); }
LogBlueprintUserMessages: [BP_MyTestActor_C_1] BP_MyTestActor_C_1 LogBlueprintUserMessages: [ChildActor_GEN_VARIABLE_BP_MyTestActor_C_CAT_192] ChildActor_GEN_VARIABLE_BP_MyTestActor_C_CAT
UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
LogBlueprintUserMessages: [BP_MyTestActor_C_1] BP_MyTestActor_C_1 LogBlueprintUserMessages: [ChildActor_GEN_VARIABLE_BP_MyTestActor_C_CAT_176] ChildActor_GEN_VARIABLE_BP_MyTestActor_C_CAT_176
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-191334 in the post.