Hi, i have a custom class Cue_BP which has individual variables. I need to take the class of this Blueprint as a parameter to the function in C++ code. How to do it?
You need to make a C++ class parent of the blueprint you wanna edit. For what I know, you can’t access blueprint classes directly from C++.
Just to confirm, you require to specify the class of a blueprint class (not an instance) and pass it to a function defined in C++.
Now for the class to offer a usable interface once passed to your C++ function, you’ll of course need to know the base class of the blueprint which declares the interface upon which you will operate. So I assume that you have a common base class from which this blueprint derives. This base class will of course need to be defined in C++ (as Scienzatogm correctly states).
With these above assumptions, it’s relatively straightforward to crate a function that takes on your BP class:
UCLASS(...) class MY_PROJECT_API AMyCppClass: public AActor
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable)
virtual void BpClassFunction(TSubclassOf<AMyBaseClass> MyDerivedClass);
...
If you wanted another function defined in C++ to pass this class type to the function (as your question suggests), you’d need to have a property exposed to the editor in which you define the “value” of the subclass (ie. your class type).
UCLASS(...) class MY_PROJECT_API AMyCallingClass : public AActor
{
GENERATED_BODY()
void CppCallingFunction()
{
MyCppClassInstance.BpClassFunction(DerivedClass);
}
protected:
UPROPERTY(BlueprintReadWrite) TSubclassOf<AMyBaseClass> DerivedClass;
...
So it’s really about the integration between C++ and blueprint; the blueprints are based on top of C++ classes so there needs to be some blueprint integrated function or property in your approach in order to supply the class information to back up to your C++ function.