Add a value the class keeps, pick its type, expose it in the Inspector, and give it a starting value.
Build + UnderstandUpdated
On this page
A value the class keeps between frames, such as a speed a designer tunes or a count the game tracks, lives in a variable. You add it from the Variables list in the left rail and set it up in the right rail.
Each variable is one row in the Variables list, showing its name and type beside a dot in its type color. Selecting the row fills the right rail with everything about it: whether it is Shown in the Inspector, who can read it, its type, its Inspector labels, and its Default card, which holds the value it starts with. When you change one variable, the others keep their order and their labels. Their notes stay too. Every variable you add becomes a pill you can drag onto any method canvas in the class.
Properties that simply expose storage also belong under Variables. A property with behavior in its getter or setter appears under Methods instead. Properties: Variables or Methods? shows the difference and explains why a backing field may still have its own row.
Add a variable when the class needs to remember something or a designer needs to tune it: the player’s move speed and jump force, the number of coins that opens the door, a reference to the Rigidbody2D on the same object, whether a coin has already been collected. Give it a starting value when it should begin at something other than zero or empty, such as a move speed of 8.
The Default card tells you where the starting value came from. From your code means Round Trip found a starting value already in the script. Implicit means the variable has none and starts at C#’s default for its type. Edited · draft means you have changed it and not yet pressed Compile.
Figure 1. The Variables list with its + in the header. Each row shows the name and type beside a type-color dot. A row whose starting value can be opened as a diagram has a DEFAULT row under it.
Pick the class in the class picker at the top left of the Round Trip graphs window so its Variables list fills the left rail.
Add a variable and name it
Press + on the Variables header (tooltip Add a variable to this class.). A new row appears with its name ready to type. Type the name, such as moveSpeed, and press Enter.
Choose its type
Click the type under Declaration in the right rail to open the type chooser, then pick float. Type in the search box to narrow the list.
In the right rail, turn on Shown in the Inspector if a designer should tune it.
Type a starting value
Find the Default card in the right rail and type a value such as 8 into its VALUE row.
Edit an existing default live
Select a variable that already has a starting value, such as gravityScale, and change the number right on its Default card. Reset to recognized puts the value from your code back.
Open a worked-out default as nodes
If the starting value is worked out from other values rather than typed, a DEFAULT row appears under the variable in the left rail. Click its chip (tooltip Open default graph) to see the value as nodes on a canvas. Click Rail to go back and make changes.
If you also work in C#, this is what is written into the script. These declarations are drafted on Enemy in the Platformer sample, with typed starting values and Inspector labels:
A new variable is written after the class’s last field, in the file’s own spacing. Changing a starting value replaces only that one declaration.