Skip to content

Nested UDictionaries are sharing values #8

Open
@digiholic

Description

@digiholic

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.

image

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions