exposing structs/classes to BP, and question about TSubobjectPtr

I know how to expose basic data types but what about my own structs or classes? I’d like for my BPs to be able to get/set some of these objects. Also, in regards to UClasses, I’m a bit confused on the best way to do this. From examples I’ve seen it looks like I generally do a UPROPERTY on a TSubobjectPtr, which seems to work. But I can’t really tell from the documentation about what exactly a TSubobjectPtr is. If someone could clarify that a bit that’d be helpful, and whether or not there are other possible templates I can/should use (and when) instead of this one. Lastly, with a TSubobjectPtr, I notice there’s a TEXT field when I do a CreateDefaultSubobject. Is this text field just how the object will appear in the blueprint? And does it have to be globally unique? Thanks!

Adding USTRUCT(BlueprintType) above your struct declaration should make usable in BPs (you can create a var of that type, will automatically offer make/break nodes for it etc).

TSubobjectPtr is a special thing just for ‘subobjects’ - UObjects which are created in a constructor, and are always part of an instance of that class. The most common use case is components of an actor defined in C++. If you are creating a UObject dynamically, then you can just use a regular UObject*, but you probably want to make sure it is a UPROPERTY so that the garbage collection system knows about it. The name you give when you create a subobject is to allow derived classes to change the class of that subobject using SetDefaultSubobjectClass e.g.:

ASphereReflectionCapture::ASphereReflectionCapture(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<USphereReflectionCaptureComponent>(TEXT("NewReflectionComponent")))

Dear James,

I tried adding just the BlueprintType part to one of my CPP USTRUCTS

It does appear as a variable type as it always has, but I do not see the make/break as having been added automatically.

Is the automatic make/break something to look forward to in 4.3?

I hope you are having fun today James!


Did you added any

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=“Category”) to your properties. The decoration might vary, but you need to expose the property to blueprint.

When you drag off any struct pin and release it should offer to make/break it, that has been in since 4.0 I believe!

Ahh that was it! Thanks Iniside!

I was only add UPROPERTY(), not elaborating and adding EditAnywhere etc.

Thanks JamesG and Iniside!


Here’s a pic!

I am going to add this to my USTRUCT tutorial :slight_smile:

EDIT: Added here



Doesnt work actualy. I made struct in c++ its visible in blueprint, but nor break or make for it.

same here, some new tut?

Nevermind, working now