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

What gets written

See which canvas changes touch one spot in the script, which rewrite a whole method, and which never reach the script.

Typing a new number into one pin should not reshuffle a whole script. When you press Compile, Round Trip changes the smallest part of the script it safely can.

A canvas holds three kinds of change. Some change one small thing the game does, such as a typed value. Some change the shape of a method, such as a new BRANCH node or loop. Some only change how the canvas looks, such as where a node sits. Compile treats each kind differently, so a teammate who reads the script afterwards sees only what you meant to change.

Keep this in mind when you review a change before pressing Compile, or when a teammate asks why a script changed. A typed value or a variable’s starting value changes one spot. Adding or removing a BRANCH, a loop, a switch, or a try catch node rewrites that one method from top to bottom. Dragging a node to a new place changes nothing in the script at all.

Code and visual scripts in one loop, on PlayerController.CollectCoin in the Platformer sample: open the method, edit its C#, create a new method visually, then Compile the draft into the file.
Code and visual scripts in one loop, on PlayerController.CollectCoin in the Platformer sample: open the method, edit its C#, create a new method visually, then Compile the draft into the file.

The loop shows a method built on the canvas being saved into the script and reloading on the canvas.

For a smaller comparison, these two captures show PlayerController.AwardPickup with the same call and target, but a different literal. They illustrate the visible value change. Neither frame is a version-control diff or a Compile status panel.

Isolate a one-value change

Select a screenshot to enlarge it.

AwardPickup calls AddCoins on _scoreCounter with count set to 1.
Figure 1. Compare the original literal The count input holds 1. _scoreCounter supplies target and the white wire reaches AddCoins; neither connection needs to change to adjust the amount.
The same AwardPickup call has count set to 2 with the target and exec wires unchanged.
Figure 2. Compare the changed literal Count now holds 2, with the same target and exec wiring. A focused write changes the argument in the call rather than replacing the surrounding method. Review the actual source diff after Compile.

Retype a value, add a BRANCH, and compile

  1. Retype a number

    On a method canvas, click the value beside a number pin and type a new number.

    MULTIPLY's right pin now holds 7 instead of 5, highlighted, with the Previewing your changes banner reading 1 node isn't in the C# yet.
  2. Add a BRANCH and wire it

    Right-click empty canvas and pick branch under flow control. Drag the white wire through the yellow BRANCH node, from the node before it into its Exec pin and from its true pin onward, and wire a red yes-or-no value, such as a comparison’s Result, into Condition.

    Clip: right-click empty canvas and choose branch from the menu (typing to search); a yellow BRANCH node lands unwired. Drag white from LogFlag's exec pin through BRANCH's exec pin and from true onward to Log, then drag a second copy of LESS OR EQUAL's result into BRANCH's condition.
  3. Move a node

    Drag any node to a new place.

    Clip: BRANCH is dragged to a new spot on the canvas and stays where it is dropped; nothing else moves.
  4. Compile

    Press Compile in the toolbar.

    The whole window with the Decide draft pending: the Compile button in the toolbar and the Compile button in the Previewing your changes panel are both highlighted, with arrows pointing at them.
    Decide after Compile, with the toolbar in view and its Compile button grey: Decide, LogFlag, BRANCH and Log sit on one exec row, and the two LESS OR EQUAL nodes and MULTIPLY (holding 7) are stacked below, each feeding the node it belongs to. All seven cards are visible and separated.
    A plain git diff: Debug.Log(value * 5); is replaced by an if block wrapping Debug.Log(value * 7); LogFlag's line above it is unchanged.

When the script still matches what the canvas loaded, a small change replaces only the text it owns. This covers renaming a method, editing a comment, changing an attribute or a variable’s starting value, editing a property, adding a guard, and changing one typed value, object reference, operator, wire, or node that maps to one line. The spacing and blank lines around that spot stay as they were.

Variables follow the same rule. Changing one starting value replaces that one variable’s declaration. Adding a variable puts its declaration after the class’s last one, in the file’s own spacing and line endings.

When a Compile adds a new method, the SET nodes, return nodes, and throw nodes you built in it are written into that method once the method is in the file. A GET pill is never a line of its own: it is written inside whatever node it feeds.

When you pick a type for a variable or an input that the script does not already know about, Round Trip first writes its full name, because that always works. Once the save is done, it shortens each full name on the lines it wrote and adds the matching line at the top of the file that lets the short name work.

It shortens a name only when that cannot change what the name means. A name stays in full when another type with the same short name is already visible to the file, or when the new line at the top would bring in a second type with a name the file already uses. Lines you or a teammate wrote are left exactly as they are.

A static method you place from search or browse follows its own rule: its type is written using the name that already resolves to that type in the file. Where the file reaches the type by its short name, the call reads Debug.Log(message); where it does not, the type is written in full, such as Platformer.Runtime.Logic.CoinUnlockRule, and no line is added at the top.

Some changes alter the shape of a method: the arms of a BRANCH, the inside of a loop, the cases of a switch, the handlers of a try catch, and some changes to the order of nodes. These are written as one whole method. Before writing, Round Trip checks that every node in the method is complete and that the method it is about to write matches the one it loaded wherever you made no change. A statement you deleted from that method leaves in the same write; if Round Trip can no longer find it, it refuses rather than remove a different line.

After a whole method is rewritten, the positions of later parts of the file can move. Round Trip reloads and re-checks them before making the next change in the same save. If it cannot line them up, it stops instead of guessing.

Nothing about layout enters the .cs file: node positions, where the view is scrolled to, zoom, wire bends, and folded sections. They are saved in the diagram’s own settings file, linked to that script. That file describes how the canvas looks, never what the game does.

If you also work in C#, this is what lands in the script. A typed value change can be as small as one token. This line is a ScoreCoins draft on ScoreCounter in the Platformer sample, with 12 typed into the multiplier:

A change of shape replaces the method’s whole body and leaves its name line and the members around it alone. This body is an AddPositiveCoins draft based on AddCoins on the same ScoreCounter:

A type picked for the input of a new Configure overload on PlayerController is first written in full and then shortened. LevelRules lives in the same namespace as PlayerController, so the short name needs no new using line; a type from another namespace would also get its using line added at the top of the file:

Unity imports the saved file, and Round Trip reloads the class and canvas from it. File-writing safeguards do not replace a backup: Edits from outside explains their limits.

When it goes wrong

SymptomCheckFix
More of the method changed than expectedLook on the canvas for a BRANCH, loop, switch, or try catch node you added, removed, or rewired.That reshapes the method, so the whole method is written. Review the canvas before pressing Compile.
The next change refuses right after a big oneRead the message: it mentions parts of the file it could not line up.Let the canvas finish reloading, open the method again, then make the next change.
Full-size image