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

Snap to grid

Let every node, and every pin, come to rest on the canvas grid, so wires run straight and a layout stays tidy without nudging.

Drop a node anywhere and it lands on the nearest grid dots. Its pins land on dots too, so the wires in and out of it run straight. Snap to grid is on from the first time you open Round Trip, and it changes nothing about the C#.

You move a call node a little to the right to make room. Without a grid it stops at whatever pixel your pointer let go on. The white wire from the node before it now arrives three pixels low, a colored wire into it leaves two pixels high, and the diagram looks slightly crooked in a way that is hard to name and tedious to fix one node at a time.

Leave it on. Every way a node reaches the canvas respects the grid: a drag of one node or of a whole selection, Auto layout, a node from the canvas action menu, a drop from a rail, a paste, and a pill placed by a split. Turn it off in Preferences > Round Trip only when you need a node at an exact in-between pixel, then turn it back on.

Drag AddCoins and let go: the node settles on the nearest grid dots, while the connected wires redraw with it.
Drag AddCoins and let go: the node settles on the nearest grid dots, while the connected wires redraw with it.

In this clip from the Platformer sample, the AddCoins node is dragged up and to the right, and it settles with its corner and pins on grid dots.

Where Snap to grid anchors a node and a pillA dotted grid with two nodes and a pill. The AddCoins node starts a few pixels off the grid, then settles so its top-left corner sits on a dot. Four callouts appear in order: the node's corner snaps to a dot; its exec, target, and count pins each sit on a dot, one grid cell apart; the _scoreCounter pill snaps by its output pin rather than its rounded corner; and the wires between them run straight along grid rows.Collectexecexec_scoreCounterAddCoinsexecexectargetcounta node snaps by its top-left cornerevery pin on a dot, rows one cell aparta pill snaps by its pin, not its cornerso a wire runs along a grid rowWhere Snap to grid anchors a node and a pillA dotted grid with two nodes and a pill. The AddCoins node starts a few pixels off the grid, then settles so its top-left corner sits on a dot. Four callouts appear in order: the node's corner snaps to a dot; its exec, target, and count pins each sit on a dot, one grid cell apart; the _scoreCounter pill snaps by its output pin rather than its rounded corner; and the wires between them run straight along grid rows._scoreAddCoinsexecexectargetcount12341a node snaps by its top-left corner2every pin on a dot, rows one cell apart3a pill snaps by its pin, not its corner4so a wire runs along a grid row
A node snaps by its top-left corner; a pill snaps by its pin. Every pin row sits a whole number of grid cells from the node’s corner, so a settled wire runs along the grid.
The AddCoins node at 100% with every pin on a grid dot, and the pills beside it with their pins on dots too.
Figure 1. The AddCoins node and the pills beside it after Auto layout, in the Platformer sample. Each node’s corner is on a dot, each pin is on a dot, and each pill’s pins are on dots even though its rounded corner is not.

A node snaps by its top-left corner. Its pin rows are laid out a whole number of grid cells below that corner, and its width is a whole number of cells, so when the corner is on a dot every pin is on a dot. A pill has no useful corner: its pins sit on its vertical center, so a pill snaps by its pin instead (its input pin when it has one, otherwise its output pin). A two-pin pill, such as a member read, is widened by less than one cell so that both pins reach dots, and it is never narrowed.

Grid spacing decides which dots exist. Widen it and the next move lands on the wider grid, while the nodes grow to keep their pins on it.

Compare the grid setting and its result

Select a screenshot to enlarge it.

AddCoins receives exec and colored data wires on the 20 pixel grid.
Figure 2. Read the default 20 px spacing At 20 px the AddCoins pin rows are compact. Compare their positions with the next view of the same node.
The same AddCoins node is re-snapped to a 40 pixel grid. Its body and pin spacing are wider.
Figure 3. Move it again on the 40 px grid Change Grid spacing to 40 px and move AddCoins. The node and pin rows fit the wider grid. Its call values and behavior stay unchanged.

See snap to grid in action

  1. Build a method with a Log

    In the left rail, click + on the Methods header and press Enter: a magenta entry node appears. Right-click empty canvas to its right, type Debug.Log into search and click Log(object message). A dark teal call card titled Log lands near your click. Drag a white wire from the entry node’s Exec pin to the Log node’s Exec pin.

    Clip: the pointer presses + on the Methods header in the left rail and a magenta NewMethod entry node appears; the + is highlighted with an arrow pointing at it while it is pressed. Then UnityEngine.Debug.Log(object message) is chosen from the canvas menu and the entry node is wired to Log.
  2. Add the reads

    Right-click below the Log node, search for gameObject, and click get on its row. Repeat for enabled. Drag the gameObject pill’s dot to the message pin. A purple wire joins them.

    Clip: choose get for gameObject and enabled in the canvas menu, then wire gameObject to the Log message pin.
  3. Move one node

    Drag the Log node by its title to anywhere on the canvas and let go.

    Clip: drag the Log card by its title and release it on the grid.
  4. Move a selection

    Drag a selection box around the Log node and both pills, then drag any one of them.

    Clip: draw a selection box around the Log card and both pills, then drag the selection.
  5. Reset to Auto layout

    Click Auto layout on the toolbar and confirm Reset to Default Layout?.

    Clip: select Auto layout and confirm the reset, then view the arranged graph. The Auto layout button on the toolbar is highlighted with an arrow pointing at it.
  6. Widen the grid

    Open Preferences > Round Trip and find GRID & CANVAS. Set Grid spacing to 40 px, then move the Log node again.

    Clip: Round Trip preferences open, Grid spacing changes from 20 to 40, then the Log node moves. While the Grid & canvas settings show, the Grid spacing row is highlighted with an arrow pointing at it.
  7. Switch snapping off and on

    In the same section, switch Snap to grid off. Move the Log node to a spot between two dots and release it. Switch Snap to grid back on and move the node once more.

    Clip: Round Trip preferences open and the Snap to grid switch is turned off, then Log is dragged between the dots. The preferences open again, the switch is turned on, and Log returns to the grid. The Snap to grid switch is highlighted with an arrow pointing at it each time the preferences show.

Nothing in the script. A snapped position is a layout position, and layout lives in the method’s .rt.json layout file beside the other view state. If you want to see it, this is the Log node’s entry after a drag released at x 533, y 147 snapped it to the nearest dot, trimmed to its id and position:

Snapping rounds the x and y a move would have saved anyway. The class’s .cs file is byte-for-byte unchanged by a drag, by a spacing change and by Auto layout, and Compile has nothing to do with any of them. Snap to grid and the other grid controls are your own preferences, stored in Unity EditorPrefs, so your teammate’s canvas and your commits are unaffected.

When it goes wrong

SymptomCheckFix
A node will not sit between two dots.Snap to grid is on, which is its default.Switch Snap to grid off under Preferences > Round Trip for the exact placement, then switch it back on.
A node lands between dots after a drag.Snap to grid is off, or the dots you are looking at are from a different Grid spacing than the one set now.Switch Snap to grid on and check the Grid spacing value, then move the node again.
After widening Grid spacing, nodes that were already placed still sit on the old grid.Spacing changes where the next release lands. Nodes are never moved behind your back.Move the nodes you care about, or click Auto layout to put every node on the new grid.
Align top or Align left left a node between dots.The align commands move nodes to the primary node's edge or center, which need not be a grid line.Drag the aligned node a short distance and release it, and it snaps.
Snap to grid changed in Round Trip but not in Behavior Tree, or the other way round.Each Bit Quirky visual editor keeps its own Snap to grid value and default.Set the preference in each editor you use.
Full-size image