Announcement

Collapse
No announcement yet.

How to cast to Blueprint class from C++?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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

    Comment


      #3
      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.

      Comment


        #4
        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.

        Comment

        Working...
        X