Skip to content

Serialized Dictionary does not update changes to GUI #4

@JoshMayberry

Description

@JoshMayberry

If I modify the SerializedDictionary during runtime with code, the inspector window does not update to show the changes.
I verified that the change was made using the debugger.

Here's a minimal example of how I had it set up:

using AYellowpaper.SerializedCollections;

public enum BuildingResource {
    Gold,
    Wood,
    Stone,
    Gem,
}

public class Example {
    public SerializedDictionary<BuildingResource, int> resources;

    public void AddResource(BuildingResource resource, int amount) {
        if (!this.resources.ContainsKey(resource)) {
            this.resources[resource] = 0;
        }

        this.resources[resource] += amount;
    }

    public void TestGainGold() {
        this.AddResource(BuildingResource.Gold, 10);
        Debug.Log($"Gold Added; {this.resources[BuildingResource.Gold]}");
    }

    public void TestGainWood() {
        this.AddResource(BuildingResource.Wood, 10);
        Debug.Log($"Wood Added; {this.resources[BuildingResource.Wood]}");
    }
}

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