Instanced UPROPERTY changes back to None after value selection

Hi everyone!

I am using UE 5.1. In my map, I have an APickup actor instance with a UPickupComponent actor component:

image

This component has the following instanced UPROPERTY():

// Used as template to create the pickup when spawned in.
UPROPERTY(EditAnywhere, Instanced)
TObjectPtr<UInventoryItem> _itemTemplate = nullptr;

, where UInventoryItem is a UObject with the following specifiers:

UCLASS(Blueprintable, EditInlineNew, DefaultToInstanced)
class INVENTORYCORE_API UInventoryItem : public UObject {
    // ...
}

Now, since I am using Instanced along with EditInlineNew and DefaultToInstanced, I expect to be able to select my _itemTemplate property from the dropdown menu:

image

For example, by selecting BP_HealthPotion, I expect the _itemTemplate pointer to point at a BP_HealthPotion instance.

However, as soon as I select any value, the editor automatically changes it back to None.

backToNone.mkv (1.6 MB)

My question is: Why is this happening? Am I doing something wrong? Or is this some kind of bug?

I tried digging a bit into the engine code, following the call stack that leads to my component’s PostEditChangeProperty(). I noticed that from FPropertyValueImpl::ImportText() I get to FObjectProperty::ImportText_Internal() with the Result local variable storing what I expect. However, when the Data variable is fed to FObjectProperty::GetObjectPropertyValue(), I get a NULL ObjectValue, which I believe is what causing the problem.

Any ideas?

I ended up finding the fix time ago and forgot to write it here.

The problem was that my UPROPERTY(Instanced) was within a UActorComponent. By moving the property to the owner AActor, its instanced value could be set.

I never understood why Instanced doesn’t work with UActorComponents’ properties though. If I have to guess, I’d say that’s because it’s a specifier meant to work with stuff that can be placed in the level.

1 Like

I’ve the same issue. Thanks for coming back and answering to it.

1 Like