Scripting / Instructions
Action
MonoBehaviour that bridges an instruction C# type and its InstructionLayout prefab. One Action component lives on each draggable item in the instruction palette. When the player drags an action onto the sheet, InstructionSheet calls CreateInstruction() and CreateLayout() to build the runtime pair.
Inspector Fields
| Field | Type | Description |
|---|---|---|
instructionType | SerializedType<PlayerInstruction> | The concrete PlayerInstruction subclass this action creates. Set this to your custom class in the Inspector dropdown. |
layout | InstructionLayout | The InstructionLayout prefab that provides the visual widget for this instruction on the sheet. Use the matching layout type for the instruction kind: plain InstructionLayout for standard instructions, InstructionModifierLayout for modifiers, and so on. |
Methods
| Method | Description |
|---|---|
CreateInstruction() | Instantiates a new PlayerInstruction of the type set in instructionType using Activator.CreateInstance. Returns the new instance. |
CreateLayout( | Instantiates the layout prefab under container and binds it to instruction. Returns the new InstructionLayout. |
CreateLayout( | Same as above but inserts the layout at the specified sibling index instead of appending. |
Load( | Restores a layout from a saved instruction — calls layout.Load() instead of CreateInstance() to rebuild the widget without triggering add-sounds or undo snapshots. |
Setting up an Action in the Palette
- In the scene's palette GameObject (a child of the instruction panel), duplicate an existing Action GameObject or create a new one.
- On the
Actioncomponent setinstructionTypeto your custom PlayerInstruction subclass. - Set
layoutto the InstructionLayout prefab that matches your instruction type. - The DragAndDrop component on the same GameObject handles the drag interaction automatically — no additional wiring is needed.
See Create an Instruction for the full end-to-end workflow including the C# class and prefab setup.