My custom editor not saving the changes.

So… My custom editor works this way:

Objects involved
→ Node
→ Connection (It’s like an output from the node, every node has 4 connections)
→ Branch (An object that is connected to one connection in two different nodes)

The Editor was created on Node, I can select which Node to connect and where on the node (Connection) to connect.

When connecting: Create a branch and connect to both connections and changes the variable “connectedBranch” in both connections to this newly created branch.

This is the newly created branch and the element 0 and 1 are both connections (Arrows) that this branch is connecting.

And this is the connection, note the branch is currently connected to it.

But now, let me try clicking on play.
The branch that was created using the editor keeps working as fine.

But, the connection node that was just had one of it’s variables changed lost all the changes.

While I’m in the Editor, everything works just fine, with no problems, but when I reopen the scene or play the game these connections loses the branch reference.

Tried manually through the inspector asign the branch, and it worked, it ONLY happens through the custom Editor.

Here are the screenshots of the error happening to me.

After a lot of debugging and searches, I made all these changes

Added [Serializable] on the NodeConnection class.
When I modified the object, I used both RecordObject(connection, “reason”) and EditorUtility.SetDirty(target)

at the end of every cicle i added on the editor code serializedObject.ApplyModifiedProperties();

Now I just need to find out what was useful and what was just wasteful.