Scripting / Instructions
InstructionSheet
Central UI manager for the instruction sheet. Owns the ordered list of InstructionLayout widgets, handles drag-and-drop onto the sheet, drives the execution cursor, and maintains an undo/redo history of up to 20 snapshots.
Static Access
| Member | Type | Description |
|---|---|---|
current | InstructionSheet | Singleton set in Awake(). Use this to interact with the sheet from any script. |
containerRect | RectTransform | Static reference to the sheet's scroll container. Used by layout widgets to compute drop positions. |
Inspector Fields
| Field | Type | Description |
|---|---|---|
container | Transform | Parent transform under which all InstructionLayout instances are spawned. |
insertIndicator | RectTransform | Visual line that previews the drop position while an instruction is being dragged over the sheet. |
pointer | RectTransform | Execution cursor that lerps to the currently executing instruction during a run. |
pointerMoveSpeed | float | Lerp speed of the execution cursor. Default: 4. |
playButton | Button | Starts execution. Disabled while running. |
stopButton | Button | Stops execution. Enabled while running. |
clearButton | Button | Destroys all instructions on the sheet. |
speedDown | Button | Sets Time.timeScale to 1 (normal speed). |
speedUp | Button | Sets Time.timeScale to 2 (fast-forward). |
undoButton | Button | Reverts the last sheet mutation. |
redoButton | Button | Re-applies the last undone mutation. |
audioSource | AudioSource | Used to play sheet SFX. |
indicatorMoveSound | AudioClip | Played when the insert indicator moves to a new position. |
addInstructionSound | AudioClip | Played when an instruction is added to the sheet. |
removeInstructionSound | AudioClip | Played when an instruction is removed. |
Properties
| Property | Type | Description |
|---|---|---|
Layouts | IReadOnlyList<InstructionLayout> | All InstructionLayout widgets currently on the sheet, in order. |
lastSibling | InstructionLayout | The last layout in the list, or null if the sheet is empty. |
instructionDatas | SerializedInstruction[] | A snapshot of the current sheet state as serializable structs. Used internally by the undo system and by LevelManager for save/load. |
Methods
| Method | Description |
|---|---|
Insert(int index, Action action) | Creates a new instruction from action at index. Saves a snapshot for undo. Called by layout widgets when an instruction is dropped above or below an existing one. |
RemoveInstruction(InstructionLayout layout) | Removes the given layout and its instruction from the sheet. Saves a snapshot for undo and plays the remove sound. |
ClearSheet() | Destroys all layouts and instructions. Saves a snapshot so the clear can be undone. |
SpeedUp() | Sets Time.timeScale to 2. |
SpeedDown() | Sets Time.timeScale to 1. |
Undo() | Pops the undo stack and restores the previous snapshot. Pushes the current state to the redo stack. Also triggered by Ctrl+Z. |
Redo() | Pops the redo stack and restores that snapshot. Pushes the current state to the undo stack. Also triggered by Ctrl+Y. |
Load(LevelInfo level) | Populates the sheet from saved instruction data stored on level. Does not save a snapshot or play sounds. |
PlayAddInstructionSound() | Plays the addInstructionSound clip. Called by sequence and modifier layouts when a child instruction is added. |
UpdateLayoutRect(InstructionLayout layout) | Sets the execution cursor's target to the given layout. Called by the runner as it advances through instructions. |
SetInsertIndicatorInactive() | Hides the insert indicator. Called when a drag ends without a valid drop. |
Undo / Redo System
Every mutation (add, remove, insert, clear) automatically calls SaveSnapshot() before the change, which pushes a SerializedInstruction[] copy of the sheet onto the undo stack. The stack is capped at 20 entries. Any mutation after an undo clears the redo stack.
Restoring a snapshot destroys all current layouts and rebuilds them from the saved data using Action.Load() — this path does not trigger sounds or additional snapshots.