Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Resolved My custom editor not saving the changes.

Discussion in 'Testing & Automation' started by shunaky, Sep 21, 2020.

  1. shunaky


    Jul 26, 2018
    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.
    View attachment 702846

    This is the newly created branch and the element 0 and 1 are both connections (Arrows) that this branch is connecting.
    View attachment 702852
    And this is the connection, note the branch is currently connected to it.
    View attachment 702855

    But now, let me try clicking on play.
    The branch that was created using the editor keeps working as fine.
    View attachment 702858
    But, the connection node that was just had one of it's variables changed lost all the changes.
    View attachment 702861

    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.
  2. shunaky


    Jul 26, 2018
    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.