Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.89.0
Menu

Enums and data classes

Create named states and source-backed fields for gameplay configuration.

An enemy is easier to reason about as Patrolling, Stunned, or Defeated than as three unexplained numbers. A level is easier to tune when its thresholds and forces live together.

The Platformer uses EnemyState for named enemy behavior and LevelRules for progression and movement values. Both need ordinary C# declarations that Unity and the rest of the project can read.

Use an enum for a closed set of named choices. Use a data class or ScriptableObject when several related values need names, types, attributes, defaults, and a stable place in source.

Round Trip indexes enums as types. Their Members section preserves declaration order and shows written values. Data-class authoring records field modifiers, attributes with arguments, inline comments, and declaration order so focused edits do not rearrange the rest of the type.

The ApplyState switch using EnemyState
Figure 1. The EnemyState switch and its case arms.

EnemyState is a compact enum with three members. LevelRules is a ScriptableObject whose fields are grouped by [Header] attributes and initialized from named constants.

  1. Choose Assets > Round Trip > New Class.
  2. Select enum as the kind, enter EnemyState, choose its folder and access, then create the draft. An enum has no parent class.
  3. In the enum’s Members section, add Patrolling, Stunned, and Defeated. Leave Value empty for implicit numbering, or enter an explicit C# value.
  4. Reorder your work by removing and re-adding only when that source change is intended. Unity stores enum fields by number, so the editor warns when an edit moves saved numeric values.
  5. For a data type, create a class or choose a ScriptableObject parent.
  6. Add fields from the Variables section. Give each field a name, type, access, attributes, and, for constants, a required value. The type row opens the project-wide type chooser, so EnemyState, Unity types such as Rigidbody2D, and generic types such as List<T> can be chosen; a generic type then asks for each type argument in turn.
  7. Use Shown in the Inspector and the Inspector tooltip controls when the field should carry [SerializeField] or [Tooltip].
  8. Press Compile in the toolbar. New fields are written after the class’s last field, in creation order and in the file’s style.

When it goes wrong

SymptomCheckFix
A new enum offers a parentCheck whether the kind is still class.Choose enum. The parent cards become unavailable because an enum has no parent.
A field remains pendingCheck for a missing name or type, or a constant with no value.Complete the declaration, then Compile.
An enum warns that saved values moveCompare the before and after numeric values shown in the warning.Keep the change only when updating saved Unity data is intended.
Full-size image