Dictionary Drawer: changing the key value of element to be added will change the key of an existing element

Issue #196 resolved
Former user created an issue

As the attachment image displayed, when I click the dropdown list in place 1 to change the key value, it will change the key value in place 2. the key value in place 1 will not change.

Step to reproduce:

1) Create a class inherited from SerializedScriptableObject 2) Embed a field with generic Dictionary<> 3) Create two elements in this Dictionary 4) Try to create the third element, when you click the dropdown in new element editor (place 1), it will change the key value of the last element in the dictionary.

Unity 2017.1, Odin (, a patch version sent from you), OSX 10.12.4

Comments (9)

  1. Tor Esa Vestergaard
    • changed status to open

    This isn't strictly a bug, merely some behaviour that's a bit confusing. If you try keeping track of the values associated with each key, you will in fact find that you are changing the correct key/value pair - its location in the order of rendering just changed along with the change of the key.

    Entries in dictionaries are always visually sorted by their keys in Odin, you see, since dictionaries have no inherent concept of the order of anything, and if we didn't do it, then some very strange behaviour would occur sometimes, with all the keys shifting around randomly as you add elements to the dictionary. The confusion you're experiencing is a common issue with this approach, though, and we've been pondering for a while how to resolve it properly.

    One thing we considered was merely ordering the keys once, when the inspector is first opened, and then afterwards leaving them as is in the order, adding elements on to the end. Then the order of keys would not change in that "inspector session", and it is only when a reload occurs, or the inspector is next opened to show that dictionary, that the keys will be ordered again.

    How does that sound?

  2. Edward Liao

    Sorry, I don't really get your point. Let me clarify the issue.

    Here are the facts:

    1. I had add two entries to the dictionary
    2. Now I'm going to add the third entry.
    3. In the new entry editor, I try to change its key, but it will actually change the key of the second entry.

    I don't understand why the existing entries's key will be affected by the new entry's key.

    If you take a closer look at my screenshot, you will understand what I mean.

    Is that make it clear? Thanks.

  3. Edward Liao

    For example, the dictionary already has such data:

    { "A": 123, "B": 456 }

    And now I want to add the third entry "C": 789, so I change the key in new entry editor from its default value to "C", strangely, it will change the second entry's key from "B" to "C", the data of dictionary will be changed to this:

    { "A": 123, "C": 456 }

    It is something I can not really understand.

  4. Tor Esa Vestergaard

    Oooohh, I understand what you are saying now - I apologize for the misunderstanding. There is currently a subtle, very hard-to-replicate issue that we're having right now, where changing the value of one dropdown will mysteriously instead change the value of a different dropdown somewhere else in the inspector. This is very likely related to Unity's control ID system, and we haven't yet managed to figure out what exactly is going on.

    It sounds like you've found a case that reliably replicates this rather rare issue - can you please give me a code sample containing your dictionary declaration, as well as the types that are in it, so I can replicate your exact inspector setup to reliably reproduce the error?

  5. Tor Esa Vestergaard

    Hello. Are you still experiencing this issue? We would still very much like a sample of your code that replicates this issue, as we've still proven unable, despite much trying, to replicate it on our own.

  6. Edward Liao

    Hi Tor,

    I am still experiencing the same issue randomly.

    I will let you know when I find a deterministic way to reproduce it.

    Sorry for keeping you waiting, I was working on other stuff recently.

    This week I will be back to my game and reproduce the issue.

    Liao Wei.

  7. Bjarke Elias

    It's fixed, and a hotfix will be submitted to the Asset Store soon. If you want it sooner, you can send me a mail to bjarke@sirenix.net with your Odin Invoice number for verification, and I'll send the build your way.

  8. Edward Liao


    I just tested today, and I found another serious issue: after upgrade, a lot of data is missing from my serialized object.

    I was upgrading from to, looks like it is not back compatible, is this by design, or just another bug?


    Before upgrade. 1.png

    After upgrade. 2.png

  9. Log in to comment