Create an Instruction Layout
Every player instruction needs a prefab that renders it as a draggable widget on the sheet. This page walks through duplicating one, choosing the right layout component, configuring it, and wiring it to the instruction's C# class.
Overview
The instruction sheet displays each instruction as a draggable widget — that widget is an InstructionLayout prefab. Each palette item GameObject also carries an Action component that binds the widget to a specific instruction C# class and supplies the prefab that the sheet instantiates when the player places the instruction.
You never create a layout prefab from scratch. Instead, duplicate any built-in prefab from Assets/Prefabs/Player Instructions/ and adapt it. Every built-in prefab already has the correct two-level structure and all required references set up.
Step 1 — Duplicate a prefab
In the Project window, navigate to Assets/Prefabs/Player Instructions/. Right-click any built-in instruction prefab and choose Duplicate. Rename it to match your new instruction (e.g. Instruction_Teleport.prefab).
Every instruction prefab has two GameObjects:
- The root — carries the
Actioncomponent that links the widget to a C# class. - A child — carries the
InstructionLayoutcomponent (or one of its subclasses) that drives the visual widget.
Step 2 — Choose the right layout type
The child GameObject must carry the layout component that matches your instruction's base class. If the duplicated prefab already uses the right component, skip ahead. Otherwise remove the existing layout component and add the correct one.
| Instruction base class | Required layout component |
|---|---|
PlayerInstruction | InstructionLayout |
InstructionModifier | InstructionModifierLayout |
InstructionSequence | InstructionSequenceLayout |
Instruction_Use | InstructionUseLayout |
Step 3 — Configure InstructionLayout
Select the child GameObject and fill in the InstructionLayout Inspector fields. The essential ones are:
| Field | What to set |
|---|---|
icon | The instruction's icon sprite — displayed on the widget in the sheet. |
nameText | The TMP_Text label that shows the instruction's display name at runtime. |
showDirectionButtons | Enable if your instruction reads the direction field. Disable for instructions that ignore direction. |
showLoopCount | Enable to expose the loop counter badge on the widget. |
backgrounds | Array of background images — the runner highlights the active index each turn to show execution progress. |
Step 4 — Extra wiring for special layout types
Modifier, Sequence, and Use layouts require additional references on top of the base InstructionLayout fields.
| Layout type | Extra setup |
|---|---|
InstructionModifierLayout | Set actionDropEventCaller to the DropActionEventCaller component on the child slot — the area where the player drops another instruction to fill the modifier. |
InstructionSequenceLayout | Set childContainer to the Transform that will parent the spawned child layout widgets when instructions are placed inside the sequence. |
InstructionUseLayout | Wire openInventoryButton to the Button that opens the item picker so the player can assign an item to the slot. |
Step 5 — Wire the Action component
Select the root GameObject of the prefab and set the Action component fields:
- Instruction Type — Assign your new C# class (e.g.
Instruction_Teleport). This tells the sheet which runtime instruction to instantiate. - Layout — Drag the child GameObject's
InstructionLayoutcomponent (or subclass) into this slot. This is the prefab the sheet instantiates as the visible widget.
The Action component uses both references together: instructionType to create the data object and layout to spawn the corresponding visual widget.
Step 6 — Add to the palette
Drag the prefab into the palette panel in your scene (a child of the Player Canvas). Each palette item must have a DragAndDrop component — without it the player cannot drag the instruction onto the sheet.
Once placed, the instruction appears in the palette and the player can drag it to the instruction sheet during gameplay.