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

Arrays, tuples, and ranges

Build arrays and grouped values, read or change their elements, and work with slices and tuples on the canvas.

A list of checkpoints, the last spawn point, the middle stretch of a path, a coin count and a score handed back together: these use arrays with element access, and also ranges and tuples. An array holds a fixed number of elements of one type; a tuple groups values that can have different types, such as a count and a position. Each operation has its own node in the construction and collections group of the action menu.

Make array builds a list from the values wired into its element pins. Element access picks one element out of a list by position, and Set element replaces one. From end counts a position from the back, so the last element is position 1 from the end. Range names a stretch of positions and Slice cuts that stretch out of a list. Make tuple bundles a few values into one wire, and Break tuple splits a bundle back into separate named values. Make struct builds a small value such as a position or a color from its parts.

Each element and each position is its own pin, as is every bundled value, so you can see what goes in without opening anything.

Use Make array when the game needs a fixed list: patrol points, the scores that earn each medal, the sounds a footstep can play. Use Element access to pick one of them, such as the next patrol point, and From end when you want the last one, such as the final checkpoint. Use Range and Slice to take part of a list, such as every checkpoint except the first and last. Use Make tuple when one step of your visual script should hand back two or three values together, such as coins and score, without creating a new type; use Break tuple to give each of those values its own name again. Use Make struct for a value made of named parts, such as a spawn position.

To make a variable hold an array, click its type in the Variables or Local variables list. Array sits at the top of the type chooser, after var for a local. Pick it and the chooser opens again to ask what type of element it holds, so the row becomes, for example, int[] or Vector2[]. An array of arrays is not offered this way.

The complete ReadCheckpoints canvas is paired with its source in What it writes. Trace the array output to the element pick and the slice, then follow the purple tuple wire into BREAK TUPLE. Each node has a pin for every element, index, range end, or bundled value; the one screenshot keeps these relationships together.

Build arrays, tuples, and ranges

  1. Place Make array

    Right-click empty canvas and search for Make array. Pick the construction action with the [] mark.

    An empty Make array has two gray element pins and a warning that both need values.
  2. Fill the first element

    Click beside the first element pin and type 2f.

    Element zero contains 2f and the array pins are green; the second element still needs a value. The 2f entry box beside the first element pin is highlighted.
  3. Add another element

    Fill the second element with 5f. Press add pin ⊕ and fill the third with 9f.

    All three float array elements are filled; the incomplete-value warning has gone. The add pin button and the third entry box, 9f, are highlighted.
  4. Read an element

    Place Element access from the canvas menu. Wire the array’s output into Collection and enter 0 in Index.

    Place Element access, wire the array into Collection and enter index zero. While the canvas menu is open, its Element access row is highlighted.
  5. Count from the end

    Place From end and enter 1 in Operand. Wire its Index output into the reader’s Index input.

    Place From end with operand one and wire it into the element reader's index. While the canvas menu is open, its From end row is highlighted.
  6. Read a slice

    Place Range and set Start to 1, leaving End empty. Place Slice. Connect the array to Collection and the range to Range, then replace the element reader’s collection wire with the slice’s Result.

    Create an open-ended range starting at one. Wire it and the array into Slice, then feed the slice to Element access. While the canvas menu is open, its Range row and then its Slice row are highlighted.
  7. Write an element

    Place Set element and connect its Exec input to the method entry. Wire the array into Collection, set Index to 0 and Value to 3f.

    Place Set element on the white execution path and give it the array with index zero and value 3f. While the canvas menu is open, its Set element row is highlighted.
  8. Bundle three values

    Place Make tuple and fill its two inputs with 3 and 30. Press add pin ⊕ and enter 5 in the third.

    Make tuple has three filled integer inputs. The three input boxes and the add pin button are highlighted.
  9. Unbundle the values

    Place Break tuple and wire the bundle into it. Connect the white Exec pins of its companion declaration node after Set element.

    Wire Make tuple into Break tuple, then connect the Set element execution output to the companion declaration node. While the canvas menu is open, its Break tuple row is highlighted.
  10. Choose a struct constructor

    Choose Make struct, search for Vector3, and pick the constructor with x, y and z.

    Choose Make struct, then select the three-component UnityEngine.Vector3 constructor. The Make struct menu row, then the Vector3 constructor row, are highlighted while they are chosen.
  11. Compile and inspect the result

    Press Compile.

    The Compile button in the toolbar, enabled for the scratch NewMethod in FlowExamples, is highlighted.

The scratch walkthrough writes these two statements. Its unconsumed slice/read chain and Vector3 draft are not part of this method’s C#:

The separate ReadCheckpoints example below instead stores its array and consumes the reads in local declarations:

When the script already spells an array or a tuple its own way and the node’s shape has not changed, Compile keeps that spelling.

When it goes wrong

SymptomCheckFix
The Make array node stays wildcard grayLook at its element pins: none has a wire or a typed value yet.Fill the first element so the list type can settle.
Compile leaves a pick or store unfinishedLook for a required collection, index or value input without a source. Range endpoints may deliberately be empty.Fill the required input, or delete the unfinished node.
A Break tuple inside another Break tuple will not CompileLook for a bundle wired straight into a second unbundle on the same partner node.Finish that shape in C#: the canvas flattens it.
Full-size image