Skip to content
SheetForge

Enum sheets

An enum sheet defines the enums that Enum<T> columns use. You write the enum in a sheet, with no code and no plugin.

Where an enum comes from

An Enum<T> column needs a T. You can register one from plugin C# (EnumRegistry), or you can write it in the sheet.

How a sheet is recognized

A sheet is one file in a local folder, one sheet of an xlsx file, or one tab of a Google spreadsheet. These pages also call it a tab.

A sheet is read as enum definitions when either condition is true:

  • The sheet carries an @enum marker row. The tab can be named anything.
  • The tab is named exactly Enum (case-sensitive) and has no @type row.

The second rule requires @type to be absent on purpose. A data table always has it, so an existing table that happens to be called Enum keeps being a table.

A sheet holding both @enum and @type is contradictory. It is reported as EnumSheetMarkerConflict rather than guessed at.

@desc takes no part in the decision. It is legal on both kinds of sheet. On an enum sheet it describes the enum in that column, as Descriptions explains.

Sheet layout

An enum sheet has no table: no schema, no key column, no records.

One column is one enum. The @name cell holds the enum's name. Every row below it with a blank column A is one member.

@enum    | byte       |
@desc    | Damage kind| Elemental affinity
@name    | DamageType | Element
         | Physical   | Fire
         | Magical=10 | Ice
         | True       | Lightning

That sheet defines two enums. Enum<DamageType> and Enum<Element> now resolve in any @type cell. The column syntax is unchanged.

The three extras shown above, the @enum row, the @desc row and the explicit member value, are all optional. A bare @name row plus members is still a complete enum sheet.

Tip

You do not have to type that skeleton yourself. In the Data Studio toolbar, press Create sheet and choose the Enum definitions template. It lays the sheet out for you. It is one of the two built-in templates. See Create a sheet.

Member values

A member's position in its column decides its value, and Name=value pins a value.

A member cell is either a plain name or Name=value with an explicit integer. These are exactly C#'s enum rules. The first member is 0. An unnumbered member is the previous value plus one.

  • Normal / Rare=10 / Epic compiles to 0 / 10 / 11.
  • Codegen emits the = value only where you wrote one.
  • Data cells and dropdowns always use the name: Rare, never Rare=10.

A value that is not a plain integer, or that falls outside the underlying type's range, is InvalidEnumMemberValue. The range applies to values reached by auto-increment too.

Member order is fixed

The Data Studio never rearranges members and never back-fills a gap. Shifting a member would silently change values already baked into assets and stored in save files.

Descriptions

@desc describes the enum. The @desc cell of a column becomes that enum's XML <summary> in the generated code. IDEs show it as a tooltip. A data table's field @desc works in the same spirit.

An empty cell means no description. The marker row itself is optional.

Underlying type

The @enum row's cell in a column may name the C# underlying type for that enum.

The cell holds one of byte, sbyte, short, ushort, int, uint, long, ulong.

@enum cellResult
One of the type namesThat underlying type
Emptyint
No @enum row at all, on a tab named Enumint
Anything elseInvalidEnumUnderlyingType

Codegen emits public enum Grade : byte { … }.

For ulong, explicit values above long.MaxValue are not supported from a sheet. Register such an enum from plugin C# instead.

Naming and cell rules

Identifiers

Names and members must be usable as C# identifiers. A violation is InvalidEnumIdentifier.

  • Use ASCII letters, digits and _.
  • Do not start with a digit.
  • Do not use a reserved keyword.

Non-ASCII is rejected deliberately. Look-alike Unicode identifiers would produce a type nobody can tell apart from another.

Unique names

Many enums per sheet and many enum sheets are both fine. Names must be unique across all of them.

A name that a plugin already registered from C# wins. The sheet definition is rejected with DuplicateEnumName.

Blank cells and comment rows

Blank cells are skipped, not read as members. Columns may therefore have different lengths, and a hole in the middle is passed over.

Comment rows (#) are ignored anywhere in the sheet.

Empty and failed columns

A declared name with no members below it is EnumSheetEmptyColumn.

If any member of one column fails, that whole enum is dropped rather than half-registered.

Generated code

The import generates one SheetForgeEnums.cs per generated-code folder. Enums are not a per-tab output.

The file is written to the generated-code folder in the settings, in the same namespace as the generated tab types.

The file holds the enums of every workbook that generates into that folder, with one namespace block per owning workbook. See Shared enum files.

The first import creates the type, compiles it and finishes the bake after the domain reload, with no extra click. See The automatic import chain.

Bake, Export and Push

Enum sheets have no records, so they are never baked into a ScriptableObject. Export and Push leave their text alone. The import reports enum sheets separately from skipped tabs.

Add a member from a cell

You can add a member without opening the enum sheet. In the Data Studio, click an Enum<T> cell. The bottom row of its dropdown is Add a new member…. That row stages the member onto the enum sheet as one undo step. See Add a member from a cell.

A staged member is an edit that the Data Studio holds and has not yet written to the source. How an edit reaches the sheet describes the steps.

An enum registered from plugin C# does not offer that row, because code owns it.

Limits

Two boundaries apply.

Next steps