EnumFlags provides [EnumFlags] attribute to render multiple selection listbox in Inspector.
upm add package dev.upm-packages.enumflagsPlease refer to this repository about the upm command.
This package has published at Unofficial Unity Package Manager Registry.
Please setup scoped registry in Packages/manifest.json to use this package.
"scopedRegistries": [
{
"name": "Unofficial Unity Package Manager Registry",
"url": "https://upm-packages.dev",
"scopes": [
"dev.upm-packages"
]
}
]using System;
[Flags]
public enum SampleFlag
{
Foo = 1 << 0,
Bar = 1 << 1,
Buz = 1 << 2,
Quz = 1 << 3,
}Note: It's strongly recommended to set value explicitly by bit shift.
using UnityEngine;
using EnumFlags;
public SampleComponent : MonoBehaviour
{
[SerializeField]
[EnumFlags]
private SampleFlag flag = default;
public SampleFlag Flag => flag;
private void Start()
{
Debug.Log($"Value: {Flag}");
}
}