Download

How to cast to Blueprint class from C++?

I searched for a long time on many resources, but did not find a way to get the type of Blueprint class in the c++ class. I’m looking for a way to get the class type,not create an object. Just need to create containers of the same type as the blueprint class. How can I do this? Maybe I should connect some kind of library in the include? Thanks.

Uhhh, ok, I will create a c++ class, inherit the bluprint class from him, and then upcast it to my c++ class. But it seems like it’s not quite right, it’s a crutch

C++ is the foundation for Blueprint not the other way around so yes if you want to reference something in Blueprint it should first be declared in C++. You might find some hacks where you use the reflection system to grab some Blueprint properties but it should not be used in the final product.

1- Create a base c++ class . For example, AActorCTest
2- Create a Blueprint that is child of UActorCTest. You could name it BP_ActorCTest
3- lets create a third class called AMain. Lets supose that this third class has a blueprint child. In order to get access to B_ActorTest create a property :

UPROPERTY(EditDefaultsOnly,BlueprintreadWrite)
TSubClassOf<AActorCTest> bpRef;

now you can access to the blueprint from C++.
If you create a property or function on the blueprint you cannot acces it from c++ unless you use some tricks with reflections, but i think that with this setups there is no need to create properties or functions on BP.