Enums and data classes
Create named states and tunable data types from the Create new class form and the left rail.
On this page
An enum is a short list of named choices, such as an enemy’s states. A data class is a type that only holds named values, such as the tuning numbers for a level. You create both from the Create new class form in the Round Trip graphs window, or the New class window, and fill them in from the left rail.
What it does
Section titled “What it does”An enum gives each choice a name, so a switch node on the canvas shows one case per name instead of a number. In the left rail, an open enum shows a Members section in place of Variables, with its names in the order you added them and any written value at the end of each row.
A data class holds related values. A ScriptableObject class defines the data an asset can hold; an instance of it can be saved as an asset and shared between objects. Creating the class below writes its script, not an asset instance.
When to use it
Section titled “When to use it”Make an enum when something in the game is always in exactly one of a few states: an enemy that is patrolling, stunned, or defeated; a pickup that is a coin, a key, or a heart; a door that is locked, open, or sealed. Each state then gets its own case on a switch node. The Platformer sample uses an enum named EnemyState with Patrolling, Stunned, and Defeated.
Make a data class when several numbers belong together and a designer should tune them in one place: movement speed, jump force, how many coins open the door. The sample’s LevelRules is a ScriptableObject made only of such values, grouped under Inspector headings.
What it looks like
Section titled “What it looks like”

How to use it
Section titled “How to use it”Create an enum and a data class
Open the creation form
Press the + beside the class chip at the top left of Round Trip graphs. The Create new class form opens.
Name the enum and choose its folder
Enter WebsiteEnemyState under NAME. Choose Runtime > Examples under LOCATION. Check the proposed script path before creating it.
2 stepsFull size ↗Create the enum
Choose the enum card under PARENT CLASS, then press Create.
3 stepsFull size ↗Add the first member
Press + on Members, enter Patrolling, and press Enter.
Add and save the other states
Add Stunned and Defeated in the same way. Press Compile before continuing.
3 stepsFull size ↗Inspect an enum value
Select Defeated in the Members list.
Try Remove, then Keep
With Defeated selected, press Remove under On compile. Press Keep to cancel that change before compiling.
2 stepsFull size ↗Create the data class
Open the creation form again. Name the class WebsiteLevelRules, choose Runtime > Examples, select ScriptableObject, and press Create. Wait for Unity to import the new class.
5 stepsFull size ↗Add a variable
Press + on Variables, enter jumpForce, and press Enter.
2 stepsFull size ↗Choose the variable type
Click the row’s type and choose float.
3 stepsFull size ↗Expose the tunable variable and add a separate constant
For jumpForce, enable Shown in the Inspector. Under Attributes, press +, choose Header, and enter Movement. Add a separate int variable named MaxJumps, enable Constant, and give it the value 3.
3 stepsFull size ↗Compile the data class
Press Compile.
2 stepsFull size ↗
What it writes
Section titled “What it writes”If you also work in C#, this is what is written into the script. Both declarations come from the Platformer sample. The EnemyState enum:
One value of LevelRules, with its trailing note:
Editing one value keeps the type’s other values, their attributes, their trailing notes, and their order exactly as they were.
When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| The New class window still offers parent cards | Read the kind dropdown under LOCATION. | Choose enum. The parent cards turn unavailable because an enum has no parent. |
| A new value stays marked New after Compile | Select it and look for an empty name or type, or a Constant with no value. | Fill the missing part in the right rail, then Compile. |
| The right rail warns that saved values move | Compare the before and after numbers in the warning. | Keep the change only if you mean to change what saved scenes and assets hold. Otherwise press Undo. |


