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

New class and method

Draft a source-backed type and its first method, preview the graph, then Compile.

A new door behavior needs a home before it needs nodes. Start with the type, then give it one small method.

Creating a C# file by hand asks for several decisions at once: folder, namespace, type kind, access, parent, method name, return type, and parameters. A typo in any one can leave the project compiling badly.

Use Assets > Round Trip > New Class when no suitable type owns the behavior. The + beside the class chip at the top of the Round Trip Graphs window opens the same choices in place. Use Assets > Round Trip > New Method, or the + on the Methods section header, when the class exists and needs a new operation. Both flows validate identifiers and types before the declaration reaches source.

The new class window
Figure 1. The class name, location, kind, access, and parent choices.
The new method window
Figure 2. The method name, return type, and parameter rows.
  1. Select the target folder in Unity’s Project window and choose Assets > Round Trip > New Class, or press the + beside the class chip in the Round Trip Graphs window.
  2. In NAME, enter a Pascal-cased C# identifier. The field shows a local reason for empty, invalid, reserved, or colliding names.
  3. In LOCATION, choose a registered source folder. The namespace and resolved path follow that location. In the window’s create dialog, New Folder… makes a folder that does not exist yet.
  4. Choose class, struct, interface, or enum, then choose public or internal access.
  5. In PARENT CLASS, pick (none) or a base card. MonoBehaviour and ScriptableObject are always offered, whichever bases the project already uses. In the window’s create dialog, OR BROWSE ALL CLASSES lists every indexed class as another base. An enum has no parent, so it disables the parent choices.
  6. Create the draft, select the new type, and choose Assets > Round Trip > New Method. In the Graphs window you can press the + on the Methods section header instead: it adds a void method named NewMethod (or the next free name), opens its preview graph, and puts a name box on its row. Type the name and press Enter, or press Escape to keep the default. The box stays open while the preview graph loads.
  7. Enter the method name and return type. Under parameters, choose add parameter for each type and name pair.
  8. Choose create to open the preview graph, or cancel to leave without a draft.
  9. Add behavior to the preview graph. No class or method source is written while you are still arranging the draft.
  10. Press Compile. The declarations and body are written, Unity imports the file, and the parsed method graph replaces the preview.

The parent you chose brings its using 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 name callout and resolved path.Use a valid, unused C# identifier and an existing registered folder.
A parameter is rejectedCheck its type expression and name.Use a valid C# type, a unique identifier, and never void as a parameter type.
The preview has no source locationConfirm the method is still a draft.Finish the graph and press Compile to create its source span.
Full-size image