Migrating custom nodes / assets between projects.

Both node and asset are not sophisticated.

Here’s header of node base class.



UCLASS()
class DIALOGUETOOLEDITOR_API UDialogueNodeBase : public UEdGraphNode
{
	GENERATED_BODY()

public:

	UPROPERTY()
		UDialogueNodeBaseRuntime* NodeRuntimeInstance;

	UPROPERTY()
		UClass* NodeRuntimeClass;

	bool IsPositionFixed = true;
	SGraphNode* NodeWidget;

	virtual void SetRuntimeClass();
	virtual void PostPlacedNewNode();

};

I’ve removed unnecessary methods like DoubleClick(), AutoWireNewNode() and other.
NodeRuntimeInstance is an object holding all kind of data that should present in game (text, sound, conditions and others)
NodeRuntimeClass is a class name of runtime node. It is used to spawn correct instance for specific node in PostPlacedNewNode();

like this


void UDialogueNodeBase::SetRuntimeClass()
{
	NodeRuntimeClass = UDialogueNodeBaseRuntime::StaticClass();
}

void UDialogueNodeBase::PostPlacedNewNode()
{
	SetRuntimeClass();
	UEdGraph* MyGraph = GetGraph();
	UObject* GraphOwner = MyGraph ? MyGraph->GetOuter() : nullptr;
	if (GraphOwner)
	{
		NodeRuntimeInstance = NewObject<UDialogueNodeBaseRuntime>(GraphOwner, NodeRuntimeClass);
		NodeRuntimeInstance->SetFlags(RF_Transactional);
	}
}

That’s about it! The main part is slate there, so uobject functionality is minimal.
When spawning new node PostPlacedNewNode() is called and runtime instance is created. When node is copied, two copies share same RuntimeInstance so I call PostPlacedNewNode() once more and duplicate object data. In that way I have two objects with same data but different RuntimeInstances.

Problem is when I copy data from one project to another it has no idea about RuntimeInstance it’s pointing to. I guess here comes the trouble, no luck transfering UObject data in text copy
(which i do with these


	FEdGraphUtilities::ExportNodesToText(SelectedNodes, /*out*/ ExportedText);
	FPlatformMisc::ClipboardCopy(*ExportedText);

)


Asset is even more simple


UCLASS(Blueprintable)
class MUSICGAME_API UDialogueAsset : public UObject
{
	GENERATED_BODY()
public:

	UPROPERTY(BlueprintReadWrite)
		class UDialogueNodeBaseRuntime* TreeStartNode; //node the tree starts with. Containing children nodes.

#if WITH_EDITORONLY_DATA
	UPROPERTY()
	UEdGraph* DialogueEditorGraph; 
#endif //WITH_EDITORONLY_DATA

};

It is created with FactoryCreateNew() and nothing else is implemented to spawn an asset.