-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested UDictionaries are sharing values #8
Comments
So after investigating it seems that list elements reuse PropertyDrawers for each element. To get around this will require a decent rewrite of the PropertyDrawer as the ReorderableLists that are used to draw the elements will need to be moved to a dictionary in a static class and referenced by object and property path. But this introduces other problems like disposing of them when they are not drawn any more. |
Any update on this? If not, I'd be happy to take a crack at solving it if you can further point me to the relevant areas/scripts. We're making extensive use of this library in our project and would hate to replace it with a lesser serialized dictionary solution (I've tried a few and this is by far my favorite). For anyone else running into this, the data is not copied, it's just duplicated visually in the inspector. A temporary workaround is to reorder your outer List/UDictionary so the item you want to edit is listed first, then repeat, one at a time. We've been doing this, but with nested UDictionaries you can get into a weird buggy state where you can't add items to any of the inner UDictionary items, even the first/"active" item. |
Hey, sorry I actually completely forgot about this. I will see if I can get it working this weekend! :) And glad to hear you are liking it! |
No apology necessary, it's the nature of open-source! Thanks for the renewed effort. |
I have encountered an issue when attempting to use a nested UDictionary of the following type:
public UDictionary<string, UDictionary<string, Sprite>> posturesForType;
It seems that the inner UDictionary is being copied whenever a new entry to
posturesForType
is added. After creating two entries, modifying either of the inner UDictionaries will modify both. Anything added to one is added to all dictionaries.In this image, I have created two entries, and attempted to assign the first two fields of the "Civillian" Dict, and it's populated the "Proforce" Dict as well. Selecting one row will select both, and reordering would affect both.
It seems that each element is being added with a reference to the same UDictionary, rather than a copy of it. I expect this might have something to do with the default behavior of how Unity adds a new element with the
+
button at the bottom, it seems to be re-using the last value. Might it be possible to force it to add with an empty value rather than a copy of the previous?The text was updated successfully, but these errors were encountered: