Why is Unity saving copies of data into my .scene then restoring it?

Hey there,

I recently have had this odd problem. I’m trying to understand what Unity is doing when it’s saving a .scene file as far as list data is concerned.

I had this scene in where I have this data structure… When I save my scene I just realized that for some reason Unity is saving old data.

Today I had NPCs that had all of these lines of dialogue in this one scene, which are stored below in EcmdsList. The script below is attached to NPC objects and there is an inspector script which edits this data.

Now I had NPCs that were saying things like “I like the ocean” last week. This week I changed what they were saying in the inspector and saved the scene. Today when working with multi-scene editing and saving, for some reason, it brought all of my early npc dialogues back from last week! All of my newer dialogue lines that were saved (or supposed to be saved) into the .scene file were deleted, and it brought back the old npc lines (string values) from the dead to replace them!

In the .scene file the section with the dialogue looks like this:

   - target: {fileID: 114337313382546980, guid: 1c2970d23d391154f9fe6563e1ea2b18,
        type: 2}
      propertyPath: o_Lists_Base.O_Lists_PagesList.Array.data[1].EcmdsList.Array.data[0]
      value: T(/n[Some Lady]I love living near the ocean where I can hear dolphins
        all the day.,DoWait)

This is listed in one place in the .scene file above then in another place this is what’s listed:

    - target: {fileID: 114604158222534316, guid: 1c2970d23d391154f9fe6563e1ea2b18,
        type: 2}
      propertyPath: :eyes:bject.o_Lists_Base.O_Lists_PagesList.Array.data[1].EcmdsList.Array.data[0]
      value: T(/n[Some Lady]I love living near the ocean where I can hear dolphins
        all the day.,DoWait)
      objectReference: {fileID: 0}

I don’t get this…why is unity saving old data into the .scene file and in two different places non-the-less? Why when I had two scenes open in multi-scene editing including this one and saved, would it restore this data?

Here is my O_Lists.cs script which has the data structure:

    [System.Serializable]
    public class O_Lists_Page {
        public enum TriggerType { Auto, AutoButton, Button, CollideWPlayer, CollideWOtherNPC }
        public TriggerType triggerType;
        public string AutoIfCondition;
        public string ButtonIfCondition;
        public int PageToGoTo;
        public bool MemorizeIndexAndPage;
        [SerializeField]
        public List<string> EcmdsList = new List<string>();
    }

    [System.Serializable]
    public class O_Lists_Base {
        public int currentPage;
        [SerializeField]
        public List<O_Lists_Page> O_Lists_PagesList = new List<O_Lists_Page>();
    }

    public O_Lists_Base o_Lists_Base = new O_Lists_Base();

Oh, stupid me…I think I see what’s happening here…I have two instances of the data in these two forms, one is located in a script called o_base.cs and the other in o_lists.cs:

Instance 1, this is the updated data that ends up in .scene…

 propertyPath: o_Lists_Base.O_Lists_PagesList.Array.data[1].EcmdsList.Array.data[0]

Instance 2, this is the old saved data…

:eyes:bject.o_Lists_Base.O_Lists_PagesList.Array.data[1].EcmdsList.Array.data[0]

This data stuff is gonna be the end of me. It’s odd that this happened…It happened when multi-scene editing. Hmmm…I’ve gotta check my get active scene().name parts of my code.

P.S - This has not happened before except with multi-scene editing. In fact, I have no clue how it got a-hold and restored it’s previous .scene data from last week at all, since I had saved the scene a bout a bajillion times. Also, I save all the data from an xml database file that it pulls from…My only thought is just hooking into and shutting down multi-scene editing.