Custom blueprint nodes defined in python need to be refreshed every time I reopen the editor

I have two python files of interest here: “dapi” and “init_unreal”

“dapi” contains code for custom blueprint nodes (like “Launch UI” in the screenshot). “init_unreal” only contains two statements : “import unreal” and “import dapi”. The init file seems to be running on editor startup like I would expect, but the editor utility widget blueprint still fails to compile. Using “Refresh all nodes” will work and then any custom nodes will work again, but that should only be a temporary workaround.

Is there something obvious I’m missing?

In the output log on editor startup, I’m noticing these errors being logged before the python modules are imported. Could that be the issue?

This is a module lifecycle issue.
By the time “ReconstructNode” method is called by the Blueprint graph, the custom function object in python scripting module were not created yet so pins can’t be reconstructed correctly when launching the editor.

You are then forced to refresh the node, by then the “ClassDefaultObject” have been finally loaded from whatever function library class they use, so when you refresh all nodes it can capture function signatures and rebuild pins accordingly.

That can be avoided when the function signature comes from C++, for generated functions like the ones created by python code, I will pay attention if Epic ever fix this structural problem because I face the same limitations while working on systems where I have to find function signatures but the Function Library default object wasn’t loaded yet on engine startup.

I’m having the same issue. Is there any feasible workaround other than writing C++? This problem makes this extremely useful feature unusable.


[USER=“9”]Stephen Ellis[/USER]

[USER=“4894”]Tim Hobson[/USER]

In case Python scripting team is still in trouble with this:

I have solved this problem on MagicNode plugin with custom serialization of pin type info to a temp *.node * file stored into project’s Intermediate folder.

Then in node’s Reconstruct() function, I restore pin data once to a in-memory struct from the file IF a node compilation happened or when Editor just launched.
I do the call to read the file from within “CreatePinsForScript()” in a case like this. Node is reconstructed successfully even though there isn’t any real UFunction existing at the time Unreal Editor is booting and Python nodes must be reconstructed… Blueprint serialization happens much later, so when the editor is finished launching, all serialized values are set back onto Pin->DefaultValue as if the pin always existed.

All hail the Json struct serializer:

void UKCS_MagicNode::PostReconstructNode()





“ScriptData” is the struct that was loaded from file at Editor startup, then I convert it back to pins:

Script->LoadIntermediateData();  // <-- reads pin type info from file into a struct..

for (auto Info : Script->GetScriptData().PropertyInfo)
    if ( Info.ParamType == EParamType::Input )
        if ( FindPin(Info.Name) == nullptr )
            if ( UEdGraphPin * Pin = CreatePin( EGPD_Input, NAME_None, Info.Name ))
                SetPinArchetype( Pin, Info.DataType );
                NewClassPins.Add( Pin );

                ///... ...

K2_Schema->SetPinAutogeneratedDefaultValue( FindPin( Info.Name ), Info.DefaultValue );

Thanks I’ve notified the team :slight_smile: