When an undone operation is done for a UObject property that has a UEdGraph*, the modified UEdGraph nodes are lost.
This UObject needs to be created/spawned in an Editor Environment by another Object. In the repro case, it was instantiated by an actor within UFUNCTION(CallInEditor) that ends up calling NewObject.
The spawned object is stored in an Object* that is inside the actor class. This property is exposed to blueprint, so we can click on the Reset Button when the property is modified. Once the UObject is created, the UEdGraph needs to be set to a valid Graph. The user is setting the pointer to a custom created UEdGraph.
When the Actor spawns the UObject and the UEdGraph is set, the actors UObject* will be filled in the details pannel. Open the EventGraph of the UObject and modify/add some nodes. Modify the UObject Event graph. If we reset the UObject* inside the instantiated Actor making it null, and subsequently pressing Ctrl+Z to undo the reset action, the modified nodes will be deleted.
1- Create a new C++ Actor and a new C++ UObject
2- Inside the actor, create a ptr to the UObject and expose it with the property EditAnywhere. This is because we need to use the ResetToDefault action. Also create a TSubclassOf<MyObjectClass> property exposed as EditAnywhere, so we can then open the BlueprintEventGraph.
3- Inside the UObject class, create a ptr to a UEdGraph. You can also create more extra data to see that the issue is only with the UEdGraph.
4- Inside the Actor class, create a function that creates the UObject. Use NewObject and the TSubclass as parameter: NodeGraphObject = NewObject<UDataObject>(this, DataSubclass,"NewObjectName", RF_Public | RF_Transactional); Also set the UEdGraph ptr to the custom graph or the class event graph.
5- Create a new Blueprint from the C++ Actor and the C++ UObject.
6- Inside the Blueprint Actor class, set the TSubclassProperty to the Uobject blueprint.
7- Spawn the Actor in the level and call the CallInEditor function to instantiate the UObject. You should see the variable getting set inside the actor details panel.
8- Open the Graph from the UObject inside the actors details panel and modify the Node Graph.
9- Save/Compile and close it. Now reset the property so the UObject ptr is null. After this, Ctrl+Z to get to set the property to its last value.
10- Open the event graph and see that the nodes have been lost.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-221474 in the post.
4 |
Component | UE - Gameplay - Blueprint Editor |
---|---|
Affects Versions | 5.3 |
Target Fix | 5.6 |
Created | Aug 9, 2024 |
---|---|
Updated | Sep 30, 2024 |