I created a default event node in a custom subgraph of a blueprint editor. I wanted this event to auto generated within a graph i inherited from UEdGraph. I implemented this behaviour
in MySubGraphCustomSchema::CreateDefaultNodesForGraph(UEdGraph& Graph)const.
Is there a better way? How defaulted event nodes like BeginPlay, OnComponentHit are auto generated? I know they are declared as ‘UFUNCTION(BlueprintImplementableEvent)’ but what i’m asking is
how these nodes spawned automatically when you create a blueprint etc. I’m triying to is implement this kind of behaivour without using UFUNCTION() declarations.
Also how can i invoke these K2Node_Event node i just created?
I found out that KismetEditorUtilities class has a static member called AutoGeneratedDefaultEventsMap.
/** Mapping of classes to names of Events that should be automatically spawned */
static TMultiMap<void*, FDefaultEventNodeData> AutoGeneratedDefaultEventsMap;
It’s used inside the FKismetEditorUtilities::CreateBlueprint function.
/*inside the CreateBlueprint function*/
// Spawn any defined auto generated default events for the class. Only do this for the most senior class specified,
// that subclasses may have an entirely different set of default nodes if they wish.
for ( TMultiMap<void*, FDefaultEventNodeData>::TIterator DataIt(AutoGeneratedDefaultEventsMap); DataIt; ++DataIt )
{
FDefaultEventNodeData Data = DataIt.Value();
if ( DefaultNodesClass == Data.TargetClass )
{
bFoundDefaultNodes = true;
FKismetEditorUtilities::AddDefaultEventNode(NewBP, NewBP->UbergraphPages[0], Data.EventName, Data.TargetClass, NodePositionY);
}
}
AutoGeneratedDefaultEventsMap maps void* pointers to FDefaultEventNodeData. Why is DataIt.Key() not used?
But these events are created with the blueprint editor inside the FKismetEditorUtilities::CreateBlueprint function.
I want these event to be auto generated with the graph itself.
I still don’t know how to invoke an event node created with AddDefaultEventNode.
I have another problem.
This is what my graph looks like with the event node.