I have function (let’s call it “Create”) that accept TSubClassOf abstract class which has one function to implement in blueprint. Then I’m using this class to create NewObject and call that function (let’s call it Execute), then destroy it.
But I don’t understand how to rewrite “Create” function to accept this abstract class AND array of parameters which can have different types like FString, UObject and etc. I want to use “Execute” function with these parameters.
How could I make this?
1 Like
I would love to know the answer to this as well. Is it even supported in blueprints, or do blueprint that do this need to be coded in C++?
Can you show what you already have ?
Not sure what’s blocking you there.
UCLASS(Abstract, Blueprintable)
class UMyAbstractBase : public UObject
{
GENERATED_BODY()
UFUNCTION(BlueprintImplementableEvent)
void Execute(const FString& Foo, int32 Bar);
UFUNCTION(BlueprintCallable, Meta=(WorldContext="InOuter"))
static void Create(UObject* InOuter, TSubclassOf<UMyAbstractBase> InClass, const FString& Foo, int32 Bar)
{
UMyAbstractBase* Obj = NewObject<UMyAbstractBase>(InOuter, InClass);
Obj->Execute(Foo, Bar);
}
}
I added a new class inherited from UObject which became a base class for all Data Classes I need to pass into Execute function. So execute function looks like void Execute(BaseDataClass* Data)
and then I cast this Data to the class I need