{"id":14961027,"url":"https://github.com/gilzoide/unity-enum-bitset","last_synced_at":"2025-10-24T20:30:45.569Z","repository":{"id":70590318,"uuid":"458681935","full_name":"gilzoide/unity-enum-bitset","owner":"gilzoide","description":"Fast and memory efficient implementation of C#'s ISet for enums, storing data as bit masks","archived":false,"fork":false,"pushed_at":"2023-06-21T12:33:41.000Z","size":123,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T03:55:02.660Z","etag":null,"topics":["bitmask","enums","enumset","package","unity","unity3d","upm-package"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":["gilzoide"],"patreon":null,"open_collective":null,"ko_fi":"gilzoide","tidelift":null,"community_bridge":null,"liberapay":"gilzoide","issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-02-13T01:36:06.000Z","updated_at":"2024-11-28T06:56:44.000Z","dependencies_parsed_at":"2024-09-22T12:00:28.822Z","dependency_job_id":"df3ffd00-d0aa-4e70-9291-e0f9ca751142","html_url":"https://github.com/gilzoide/unity-enum-bitset","commit_stats":{"total_commits":61,"total_committers":2,"mean_commits":30.5,"dds":"0.016393442622950838","last_synced_commit":"39f2cdab659d0a0714e9437d31d3b2e995e1f0e4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Funity-enum-bitset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Funity-enum-bitset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Funity-enum-bitset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Funity-enum-bitset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/unity-enum-bitset/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238030288,"owners_count":19404859,"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":["bitmask","enums","enumset","package","unity","unity3d","upm-package"],"created_at":"2024-09-24T13:23:39.425Z","updated_at":"2025-10-24T20:30:45.248Z","avatar_url":"https://github.com/gilzoide.png","language":"C#","funding_links":["https://github.com/sponsors/gilzoide","https://ko-fi.com/gilzoide","https://liberapay.com/gilzoide"],"categories":[],"sub_categories":[],"readme":"# EnumBitSet\n[![openupm](https://img.shields.io/npm/v/com.gilzoide.enum-bitset?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.gilzoide.enum-bitset/)\n\nFast and memory efficient implementation of C#'s `ISet` for enums, storing data as bit masks:\n- `EnumBitSet32\u003cT\u003e`: uses `EnumBitMask32\u003cT\u003e` as data, supporting enums with up to 32 values.\n- `EnumBitSet64\u003cT\u003e`: uses `EnumBitMask64\u003cT\u003e` as data, supporting enums with up to 64 values.\n\nBit masks are readonly structs implementing `IReadOnlySet` for enums:\n- `EnumBitMask32\u003cT\u003e`: uses `int` as data, supporting enums with up to 32 values.\n- `EnumBitMask64\u003cT\u003e`: uses `long` as data, supporting enums with up to 64 values.\n\nAll implementations support enums both with and without `[Flags]` attributes.\n\nConversions between enum values and integer types are non-boxing where possible by using unsafe utilities from Unity 2018+, .NET 5+ or .NET Core 3.0+\n\n\n## Installing the package\nThis package is available on the [openupm registry](https://openupm.com/) and can be installed using the [openupm-cli](https://github.com/openupm/openupm-cli):\n\n```\nopenupm add com.gilzoide.enum-bitset\n```\n\nOtherwise, you can install directly using the [Unity Package Manager](https://docs.unity3d.com/Manual/Packages.html) with the following URL:\n\n```\nhttps://github.com/gilzoide/unity-enum-bitset.git#1.1.0\n```\n\n\n## Unity 2020+ Serialization and Property Drawer\nIn Unity 2020+, `EnumBitSet`s are serializable directly as generic classes.\nThere's also a custom property drawer for selecting the containing enums:\n\n```cs\nusing System;\nusing UnityEngine;\nusing Gilzoide.EnumBitSet;\n\npublic enum TestEnum\n{\n    Zero, One, Two, Three\n}\n\n[Flags]\npublic enum TestEnumFlags\n{\n    Zero = 1 \u003c\u003c 0, One = 1 \u003c\u003c 1, Two = 1 \u003c\u003c 2, Three = 1 \u003c\u003c 3\n}\n\npublic class ScriptWithBitSet : MonoBehaviour\n{    \n    public EnumBitSet32\u003cTestEnum\u003e aBitset;\n    public EnumBitSet64\u003cTestEnumFlags\u003e anotherBitset;\n}\n```\n\n![](Extras~/CustomDrawer.png)\n\n## Unity 2019- Serialization and Property Drawer\nIn Unity 2019 and earlier, create non-generic classes that\ninherit from the generic ones:\n\n```cs\nusing System;\nusing UnityEngine;\nusing Gilzoide.EnumBitSet;\n\npublic enum TestEnum\n{\n    Zero, One, Two, Three\n}\n\n[Flags]\npublic enum TestEnumFlags\n{\n    Zero = 1 \u003c\u003c 0, One = 1 \u003c\u003c 1, Two = 1 \u003c\u003c 2, Three = 1 \u003c\u003c 3\n}\n\n[Serializable]\npublic class TestEnumBitSet32 : EnumBitSet32\u003cTestEnum\u003e {}\n\n[Serializable]\npublic class TestEnumFlagsBitSet64 : EnumBitSet64\u003cTestEnumFlags\u003e {}\n\npublic class ScriptWithBitSet : MonoBehaviour\n{\n    public EnumBitSet32\u003cTestEnum\u003e aBitset;\n    public EnumBitSet64\u003cTestEnumFlags\u003e anotherBitset;\n}\n```\n\nFor the custom Property Drawer, the same applies.\nCreate a class that inherits from `EnumBitSetPropertyDrawer`:\n\n```cs\nusing UnityEditor;\nusing Gilzoide.EnumBitSet.Editor;\n\n[CustomPropertyDrawer(typeof(TestEnumBitSet32))]\npublic class TestEnumBitSet32PropertyDrawer : EnumBitSetPropertyDrawer {}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Funity-enum-bitset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Funity-enum-bitset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Funity-enum-bitset/lists"}