{"id":26512256,"url":"https://github.com/audunegames/serializable-dictionary","last_synced_at":"2026-05-19T15:31:45.498Z","repository":{"id":223901314,"uuid":"724249271","full_name":"audunegames/serializable-dictionary","owner":"audunegames","description":"Serializable version of a C# dictionary for use in Unity.","archived":false,"fork":false,"pushed_at":"2024-12-27T18:13:24.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-27T19:20:08.907Z","etag":null,"topics":["collection","dictionary","serialization","unity","utilities"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/audunegames.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-27T17:41:37.000Z","updated_at":"2024-12-27T18:13:19.000Z","dependencies_parsed_at":"2024-12-10T15:29:56.071Z","dependency_job_id":"ce078d54-1719-48b5-9767-c685c9daffa4","html_url":"https://github.com/audunegames/serializable-dictionary","commit_stats":null,"previous_names":["audunegames/serializabledictionary","audunegames/serializable-dictionary"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audunegames%2Fserializable-dictionary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audunegames%2Fserializable-dictionary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audunegames%2Fserializable-dictionary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audunegames%2Fserializable-dictionary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/audunegames","download_url":"https://codeload.github.com/audunegames/serializable-dictionary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244731671,"owners_count":20500719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collection","dictionary","serialization","unity","utilities"],"created_at":"2025-03-21T03:28:17.816Z","updated_at":"2026-05-19T15:31:45.441Z","avatar_url":"https://github.com/audunegames.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Audune Serializable Dictionary\n\n[![openupm](https://img.shields.io/npm/v/com.audune.utils.dictionary?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.audune.utils.dictionary/)\n\nSince Unity doesn't serialize dictionary classes by default, usually some serialization workaround is required to acoomplish serializing its data. This package contains a serializable dictionary class that takes away the hassle of defining custom classes.\n\n## Features\n\n* A `SerializableDictionary\u003cTKey, TValue\u003e` class to use in place of the C# `Dictionary\u003cTKey, TValue\u003e` class, but with the benefit of the data being serialized in Unity.\n* Some dictionary-related LINQ extension methods.\n\n## Installation\n\n### Requirements\n\nThis package depends on the following packages:\n\n* [Unity IMGUI Editor Utilities](https://openupm.com/packages/com.audune.utils.unityeditor/), version **2.0.0** or higher.\n\nIf you're installing the required packages from the [OpenUPM registry](https://openupm.com/), make sure to add a scoped registry with the URL `https://package.openupm.com` and the required scopes before installing the packages.\n\n### Installing from the OpenUPM registry\n\nTo install this package as a package from the OpenUPM registry in the Unity Editor, use the following steps:\n\n* In the Unity editor, navigate to **Edit › Project Settings... › Package Manager**.\n* Add the following Scoped Registry, or edit the existing OpenUPM entry to include the new Scope:\n\n```\nName:     package.openupm.com\nURL:      https://package.openupm.com\nScope(s): com.audune.utils.dictionary\n```\n\n* Navigate to **Window › Package Manager**.\n* Click the **+** icon and click **Add package by name...**\n* Enter the following name in the corresponding field and click **Add**:\n\n```\ncom.audune.utils.dictionary\n```\n\n### Installing as a Git package\n\nTo install this package as a Git package in the Unity Editor, use the following steps:\n\n* In the Unity editor, navigate to **Window › Package Manager**.\n* Click the **+** icon and click **Add package from git URL...**\n* Enter the following URL in the URL field and click **Add**:\n\n```\nhttps://github.com/audunegames/serializabledictionary.git\n```\n\n## Usage\n\n### Serializable dictionary\n\nTo use the serialized dictionary class, simply make a serialized field in a Unity component. The inspector draws a reorderable list with the contents of the dictionary:\n\n```csharp\nusing Audune.Utils.Dictionary;\n\n// It's as easy as this!\npublic SerializableDictionary\u003cint, string\u003e dictionary;\n```\n\nYou can also define options that customize how the dictionary is displayed in the inspector using a property attribute:\n\n```csharp\nusing Audune.Utils.Dictionary;\n\n// Custom headers for the keys and values\n[SerializableDictionaryOptions(keyHeader = \"Priority\", valueHeader = \"String\")]\npublic SerializableDictionary\u003cint, string\u003e dictionary;\n\n// Draw the reorderable list in a foldout and include a label with info about the dictionary (this is the default)\n[SerializableDictionaryOptions(listOptions = ReorderableListOptions.DrawFoldout | ReorderableListOptions.DrawInfoField)]\npublic SerializableDictionary\u003cint, string\u003e dictionary;\n\n// Don't draw a foldout or an info label\n[SerializableDictionaryOptions(listOptions = ReorderableListOptions.None)]\npublic SerializableDictionary\u003cint, string\u003e dictionary;\n```\n\nBecause the serialized dictionary class inherits from both `IDictionary\u003cTKey, TValue\u003e` and `IReadOnlyDictionary\u003cTKey, TValue\u003e`, access of properties and methods works just like a regular dictionary, and a reference to the serializable dictionary can be used almost in every place where one of those interfaces are expected.\n\n### Extension methods\n\nSelecting keys or values or mapping them in LINQ operations has never been easier! These extension methods work on serializable dictionaries or everything that inherits from `IEnumerable\u003cKeyValuePair\u003cTKey, TValue\u003e\u003e`:\n\n```csharp\n// Convert an enumerable of dictionary entries to a dictionary without providing selectors\nvar newDictionary = dictionary.SelectOnKey(key =\u003e key * 2).ToDictionary();\n// ... is equivalent to ...\nvar newDictionary = dictionary.Select(e =\u003e new KeyValuePair\u003cint, string\u003e(e.Key * 2, e.Value)).ToDictionary(e =\u003e e.Key, e =\u003e e.Value);\n\n// Select the key for each dictionary entry\nvar listOfKeys = dictionary.SelectKey().ToList();\n// ... is equivalent to ...\nvar listOfKeys = dictionary.Select(e =\u003e e.Key).ToList();\n\n// Select the value for each dictionary entry\nvar listOfValues = dictionary.SelectValue().ToList();\n// ... is equivalent to ...\nvar listOfKeys = dictionary.Select(e =\u003e e.Value).ToList();\n\n// Select a mapped key for each dictionary entry\nvar doubledKeys = dictionary.SelectOnKey(key =\u003e key * 2).ToDictionary();\n// ... is equivalent to ...\nvar doubledKeys = dictionary.ToDictionary(e =\u003e e.Key * 2, e =\u003e e.Value);\n\n// Select a mapped value for each dictionary entry\nvar boldValues = dictionary.SelectOnValue(value =\u003e $\"\u003cb\u003e{value}\u003c/b\u003e\").ToDictionary();\n// ... is equivalent to ...\nvar doubledKeys = dictionary.ToDictionary(e =\u003e e.Key, e =\u003e $\"\u003cb\u003e{e.Value}\u003c/b\u003e\");\n\n// Merge two dictionaries with the specified strategy\nvar mergedDictionaries = dictionary.Merge(other, g =\u003e g.First());\n// ... is equivalent to ...\nvar mergedDictionaries = dictionary.ToLookup(e =\u003e e.Key, e =\u003e e.Value).ToDictionary(g =\u003e g.Key, g =\u003e g.First());\n\n// There are also some common merge strategies defined as methods\nvar firstValuesUsed = dictionary.Merge(other, DictionaryMergeStrategy.First());\nvar lastValuesUsed = dictionary.Merge(other, DictionaryMergeStrategy.Last());\n```\n\n## Contributing\n\nContributions to this package are more than welcome! Contributing can be done by making a pull request with your updated code.\n\n## License\n\nThis package is licensed under the GNU LGPL 3.0 license. See `LICENSE.txt` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudunegames%2Fserializable-dictionary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faudunegames%2Fserializable-dictionary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudunegames%2Fserializable-dictionary/lists"}