[What I want to do]
Hi, I’m Irying call Blueprint CustomEvent function from C++.
Note that we want to do this without using BlueprintImplementable or BlueprintNativeEvent.
[What I tried]
UFunction* Function = MyClassInstance->GeneratedClass->FindFunctionByName(FunctionName);
MyClassInstance->ProcessEvent(Function, nullptr);
this code caused error.
Assertion failed: ((UObject*)ContainerPtr)->IsA(GetOwner<UClass>()) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Public\UObject\UnrealType.h] [Line: 487] 'BP_MyClass' is of class 'MyClass' however property 'UberGraphFrame' belongs to class 'MyClass_C'
There’s no variable GeneratedClass in UObject so I’m curious what is the type of MyClassInstance.
Can you show the full C++ function, or at least its signature ?
The way I see it, variable MyClassInstance should be of type MyClass*, and the code should rather look like
UFunction* Function = MyClassInstance->FindFunction(FunctionName);
I am sorry for the delay.
Thank you very much. Problem solved.
First.
I made the derived from UObject instead of from UBlueprint.
However, EventGraph(UbergraphPages?) cannot be accessed from MyClassInstance (derived from UObject), I created a MyClassBlueprint (derived from UBlueprint) separate from MyClassInstance.
(Maybe the interpretation is wrong.)
Next, I set UMyClassInstance::StaticClass to ParentClass in MyClassBlueprintFactory.
This way, when MyClassBlueprint is created in the editor, ParentClass becomes MyClassInstance and the class in BlueprintEditor becomes MyClassBlueprint.