How can I make an editable UPROPERTY?

Hi everyone,

I’m trying to make an editable HUD Component (same code but the texture on it can change) but i
immediately got stuck for this reason:

If i create the Texture component as “TSubobjectPtr”,i can make it visible in the blueprints graph but its value can’t be changed in the editor.

	UPROPERTY(VisibleAnywhere,BlueprintReadOnly, Category = "Assets")
	TSubobjectPtr<UTexture2D> TopLeftCorner;

If i instead create it without the TSubobjectPtr i can make it editable with “EditAnywhere” but i can’t get its value in the blueprint.

	UPROPERTY(EditAnywhere, Category = "Assets")
	       UTexture2D TopLeftCorner;

I tried using BlueprintReadWrite or BlueprintAssignable but i can’t use them with TSubobjectPtr it seems.
So,is there a way to allow a code generated property to be both editable in the editor and usable in the blueprint graph?

Thanks in advance.

You can look at AmbientSound.h for an example of what you want.

In particular EditInline in your UPROPERTY definition.

TSubobjectPtr is essentialy only for subobjects, which means for classes that derive from ActorComponent.

You can use it with other classes, for some niche tasks, but it’s not intended use case.

Instead create normal pointer Like:

Texture2D* MyTexture.


TAssetPtr<Texture2D> MyTexture

Thanks,that solved it.

Thanks for the tip,i’ll use TAssetPtr instead.