Does an owner of UPROPERTY member need to be also declared with UPROPERTY for garbage collector to work properly?

What would happen if I would have situation like below:

USTRUCT()
struct FChild {
   GENERATED_BODY()

   UPROPERTY()
   UObject* MyObject;
}

UCLASS()
class UParentClass: public UObject {
    GENERATED_BODY()

   FChild Child;
}

Would GC work correctly if my Child member in UParentClass wouldn’t have UPROPERTY set? Would UPROPERTY macro declared inside FChild struct be enough? Or does it need continouos UPROPERTY chain from root to leaf?

It does need a continuous chain from root to leaf, however UPROPERTY is not the only way to chain. You can also use AddReferencedObjects to manually chain objects.

1 Like