- Inside your Unity project go to Window -> Package Manager
- At the bottom left corner choose "+"
- Install package from git URL
- Paste
https://github.com/Hllib/com.hlmlabs.partialenum.git - Click "Install"
Type-safe, serializable enum-like values that can be defined across multiple files.
- Declare a
partial structwith[EnumHolder(typeof(YourType))]. - Add values as
public static readonly TypedEnum<YourType>fields on that struct. - Extend the same
partial structin other files to add more values. - Serialize
TypedEnum<YourType>on components — the Inspector shows a dropdown of all registered values.
Compare values with == / !=. Use .Value for the underlying int, or rely on ToString() for the field name.
EnumCustomType.cs
using HLMLabs.PartialEnum.Runtime;
[EnumHolder(typeof(EnumCustomType))]
public partial struct EnumCustomType
{
public static readonly TypedEnum<EnumCustomType> Default = new(0);
public static readonly TypedEnum<EnumCustomType> ValueA = new(1);
}EnumCustomType.Impl.cs — additional values in another file
using HLMLabs.PartialEnum.Runtime;
public partial struct EnumCustomType
{
public static readonly TypedEnum<EnumCustomType> ValueB = new(2);
public static readonly TypedEnum<EnumCustomType> ValueC = new(3);
}MyComponent.cs — use in the Inspector
using HLMLabs.PartialEnum.Runtime;
using UnityEngine;
public class MyComponent : MonoBehaviour
{
[SerializeField] private TypedEnum<EnumCustomType> customType;
private void Start()
{
if (customType == EnumCustomType.ValueB)
Debug.Log("Value B selected");
}
}Each value must have a unique integer. Duplicate values are reported as errors in the Console on domain reload.