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 a C# feature.

Browse the reference instead

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

v1.0.0
Menu

New class and method

Create a class and its first method from the Round Trip window, build the method on the canvas, then Compile.

New behavior needs a home before it needs nodes. Make the class first, then give it one small method and build that method on the canvas.

The Create new class form asks every question a new script needs in one place: its name and folder, its kind, and what it builds on. Pressing Create writes the new class’s script file into that folder straight away. The + on the Methods header then adds a method and opens its empty canvas. The method is not written into the script until you press Compile, so you can build and rearrange it, or undo changes, first.

Make a new class when a new kind of thing enters your game and nothing existing should own its behavior: a coin reporter, a moving platform, a checkpoint, a power-up. Pick MonoBehaviour for something you attach to a GameObject, ScriptableObject for a data asset, or (None) for a plain helper.

Add a method when an existing class needs a new action: a Report on the coin reporter, a Launch on a spring pad, a Respawn on the player.

Recognize class creation and a method draft

Select a screenshot to enlarge it.

The New class window has NAME above LOCATION set to Runtime. The PARENT CLASS cards appear below the kind and access controls.
Figure 1. Choose where the class belongs Start with NAME and LOCATION, then choose a parent. The plain class card is selected in this capture; choose MonoBehaviour for a component. The resolved script path is below LOCATION.
PlayerController has a CelebrateCoin draft selected. One magenta entry node and the Previewing your changes panel are visible.
Figure 2. Find the new method and its controls This separate PlayerController example shows a method before Compile. It is independent of the class form above. CelebrateCoin appears in both the Methods row and right-rail signature. Inputs and Outputs each have a +.

Create CoinReporter and build its Report method

  1. Open the class picker

    In the Round Trip graphs window, press the + on the right of the class chip at the top left.

    The Create new class form just opened: NAME is empty and LOCATION shows Runtime. The + button beside the class chip at the top left is highlighted, with an arrow pointing at it.
  2. Name the class

    Type a name into NAME, such as CoinReporter.

    NAME now reads CoinReporter, with no error message under the field. The NAME box is highlighted.
  3. Pick a location

    Under LOCATION, pick one of your project’s source folders in the first dropdown, such as Runtime. Pick (here) in the last dropdown to keep the class in that folder.

    LOCATION reads Runtime, Examples, (here), with the three dropdowns highlighted. The line underneath shows Runtime/Examples/CoinReporter.cs and a namespace box.
    A close-up of the same LOCATION row: the namespace box reads RoundTrip.Platformer.Runtime, the folder's Root Namespace.
  4. Pick a parent

    Under PARENT CLASS, click the MonoBehaviour card.

    PARENT CLASS: the class, enum and static (none) cards are unselected, and the MonoBehaviour card, reading Unity component, UnityEngine, is selected and highlighted with an arrow pointing at it. ScriptableObject's edge is visible.
  5. Create the class

    Press Create (also Create in the New class window).

    The filled-in Create new class form with the Create button at the bottom right highlighted, with an arrow pointing at it.
  6. Add a method

    Press + on the Methods header in the left rail. Type a name for the method, such as Report, and press Enter.

    The Round Trip window switched to the new CoinReporter class: Lifecycle and Methods are empty, and the + on the Methods header is highlighted with an arrow pointing at it.
    A magenta Report entry node alone on the canvas with white exec and gray self pins; the right rail shows its uncompiled signature with empty Inputs and Outputs.
  7. Add an input

    Press + on Inputs in the right rail. In the new row, pick the type int and type the name count.

    The entry node now also has a green count pin under self; the right rail's Inputs + button and its int, count row are highlighted.
  8. Build the method

    Right-click empty canvas and place a node from All actions, such as Log. Drag from the entry node’s Exec pin to the new node’s left Exec pin, then from the count pin into the node’s input pin.

    Clip: the pointer right-clicks empty canvas; a menu opens and Log is chosen, landing unwired. The pointer drags a white wire from the entry node's exec pin to Log's exec pin, then a green wire from count to Log's message pin.
  9. Compile

    Press Compile in the Previewing your changes. panel at the top of the right rail.

    The Previewing your changes panel at the top of the right rail with its Compile button highlighted and an arrow pointing at it.
    Report and Log nodes framed closely: Report's white exec and green count pins wire into Log's exec and message pins. The right rail shows the compiled signature public void Report(int count) with no Previewing your changes banner.

If you prefer a form, select the class in Unity and choose Assets > Round Trip > New method. Fill Name and Return type, press Add parameter once per input, and press Create to open the same empty canvas, or Cancel to leave without a draft.

The New method form for PlayerController has a blank name and void return type. Add parameter sits above Create and Cancel.

The alternative New method form starts with no name and a void return type. Use Add parameter for each input before pressing Create.

If you also work in C#, this is what is written into the script. With MyGame.Gameplay in the namespace box, the class and method from that exercise, with a log call wired to count, are written as:

The parent you chose brings its using line with it. Any type name Compile writes in full, such as UnityEngine.Debug, is shortened and its namespace imported wherever that cannot make a name in the file ambiguous.

When it goes wrong

SymptomCheckFix
Create stays blockedRead the message under NAME, the file path under LOCATION and any message under the namespace box.Type a name that is allowed and not taken, pick an existing source folder, and type a namespace of C# names joined by dots, or leave it empty for none.
The class is written in a namespace you did not expectLook for an assembly definition over the folder, the namespace the scripts beside it use, and Project Settings > Editor > Root Namespace, in that order.Type the namespace you want into the namespace box before pressing Create.
An input row is rejectedLook at its type dropdown and name box in the Inputs section.Pick a real type (never void) and a name no other input uses.
Full-size image