Scripting / UI
InstructionLayout
Base class for all instruction widgets. Renders a PlayerInstruction on the instruction sheet, handling direction cycling, loop counter adjustments, and reordering via drag-drop.
Properties
| Property | Type | Description |
|---|---|---|
instruction | PlayerInstruction | The data object this widget is bound to. |
container | IInstructionSequenceLayout | The parent sequence layout, if this instruction is nested inside a Combo or similar. null for top-level instructions. |
rectTransform | RectTransform | The widget's root RectTransform. |
anchor | RectTransform | Y-position anchor used by the insert indicator to decide whether a drop targets the slot above or below this widget. |
anchoredPosition | Vector2 | Shorthand for anchor.anchoredPosition. |
Inspector Fields
| Field | Type | Description |
|---|---|---|
lineNumber | TMP_Text | Label showing the instruction's position in the sheet (1-based). |
instructionName | TMP_Text | Label showing the instruction's displayName. |
loopText | TMP_Text | Label showing the current loop count. |
backgrounds | Image[] | Background sprites synced to the instruction's action tint color. |
directions | Sprite[] | Direction arrow sprites in order: Up, Right, Down, Left. |
directionButton | GameObject | Direction cycle button — hidden for instructions that do not use a direction (e.g. Wait). |
loops | GameObject | Loop counter section container. |
arrowsContainer | GameObject | Container for the directional arrow indicators. |
increaseLoopButton | Button | Increments the loop count (max 12). |
decreaseLoopButton | Button | Decrements the loop count (min 1). |
removeButton | Button | Removes the instruction from the sheet. |
Key Methods
| Method | Description |
|---|---|
CreateInstance(PlayerInstruction, Action, Transform) | Factory — instantiates the prefab, binds the instruction and action, sets backgrounds and labels. Returns the new layout. |
Load(PlayerInstruction, Action, Transform) | Restores a widget from saved data — same as CreateInstance but skips sounds and undo snapshots. |
Remove() | Removes this instruction from the sheet and destroys the GameObject. |
IncreaseLoop() | Increments the instruction's loop counter, capped at 12. |
DecreaseLoop() | Decrements the instruction's loop counter, floored at 1. |
SetDirection(Direction) | Sets the instruction's direction and updates the arrow sprite. |
CycleDirection() | Advances the direction Up → Right → Down → Left → Up. Wired to the direction button. |
UpdateLineNumber() | Refreshes the line number label from the widget's current sibling index. |
SyncVirtualInstruction(Instruction) | Called by the runner during execution to mirror the runtime clone's direction and loop count back to the UI. |
ResetLayout() | Restores the visual state from the instruction data after execution ends. |
Validate() | Delegates to instruction.Validate() and returns the result. |