Skip to Content
Stoatly Docs
Object types

Enums

An enum is a named list of values, like Common, Rare and Epic for an item's rarity. A field of the Enum type holds one of them, so designers pick from the list instead of typing a word that's spelled differently every time. Each enum belongs to an object type. Admins and schema designers can create and edit them.

Create an enum

Open the Enums tab

On the object type's page, choose the Enums tab.

Choose New enum

Stoatly creates the enum and opens it with its name ready to edit. Rename it, for example to Rarity.

Add the values

Type a label under New value label and choose Add value. Repeat for each value. Drag the handle on a row to reorder them.

An enum with seven values, showing each label, its C# name, its number and the Deprecate, Restore or Delete action.

To use an enum, add a field of the Enum type and pick it under Enum.

What each value has

Every value has a label, a C# name and a number.

  • The label is what designers see.
  • The C# name is the member name in the generated enum. While a value hasn't shipped, it follows the label.
  • The number is the value stored for it. It's assigned in order and shown on the row.

The enum's slug is the name of the generated C# type. It's edited separately from the name.

Change an enum after it has shipped

A value ships when a pull request that contains it merges. From then on Stoatly protects the code and the data that depend on it.

You want toBefore it shipsAfter it ships
Remove a valueDelete removes it straight awayDeprecate keeps it but stops it being chosen
Rename the labelWorks, and the C# name followsWorks, and the C# name stays the same
Change the C# nameFollows the labelEdit it on the row, after a warning
ReorderDrag the handleNot allowed, because the number is fixed

Deprecating a value stops it being selectable in new and edited records. Records that already hold it keep it and show it as deprecated. The generated C# member is marked [Obsolete]. Choose Restore to undo a deprecation.

Changing the C# name of a shipped value breaks any code that uses the old name. Stoatly searches the repository for files that mention it and lists them before you confirm. It only finds direct references, so code that uses an alias or a static import won't appear.

Delete an enum

Open Enum actions on the enum and choose Delete. An enum that has never shipped is discarded immediately. One that has shipped is marked for deletion and removed, along with its generated C# type, when the pull request merges. Stoatly lists the fields that use it first. Those fields stay, but they lose their type and generate as int?, so existing code that uses them will stop compiling.

Turn an enum into an object type

When the values need fields of their own, such as a Rarity with a colour and a drop rate, convert the enum into an object type.

On this page