Use blueprint as variable type in C++?

I’d like to write in the header file:

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Custom")
SomeBlueprint MyVariable;

How do I get Visual Studio to do this? Obviously SomeBlueprint is undefined.

Hey -

One option you can try would be to create a variable of type UBlueprint* and then in the constructor for the class, use a Constructor Helper to find the blueprint in the content browser and set the construction helper reference to your variable reference.

Typically code/blueprint communication is meant to go from code to blueprints rather than the other way around. If you are trying to provide base functionality in one and extend functionality in the other, I would suggest putting the default implementation in code and then building from that inside the blueprint.

Cheers

If you are trying to provide base
functionality in one and extend
functionality in the other, I would
suggest putting the default
implementation in code and then
building from that inside the
blueprint.

I’m just trying to ‘dance through the loops’ to make an alternative to structs Struct alternative? - Programming & Scripting - Epic Developer Community Forums

Blueprints are rather limited and I sometimes feel that I need C++. It’s just that I keep finding out that every time I use C++, I don’t need C++ knowledge, I just need a lot of UE4 knowledge, which I don’t have and which is hard to get. Been trying to get a very simple struct to work for 2 days now. Making progress rather slowly but will get there eventually.

So far I found 3 options (none of which is ideal):

I hope that someday, UE4-blueprints will allow us to pass&store structs by reference so we no longer have to ‘dance through loops’.