Layout Command¶
Puts objects onto slots: moves objects that already exist, or spawns new ones there.
Namespace: Jungle.Spatial
Runs in: a Process Component, a reaction, or any other process.
Overview¶
Add Component > Jungle > Spatial > Layout gives you a Process Component that runs a Layout Command with one Arrange step. Each step names its own slots, so the command has no target.
- Arrange finds the objects to move, asks the slots for one place per object, and moves each object there in order. Extra objects or extra slots are left alone. It finishes the frame it starts.
- Spawn (Scatterpillar, Add Component > Jungle > Scatterpillar > Spawn Layout) asks the slots for Count places and creates one object per place from a creator. With Despawn On End on, it keeps running and gives every object back to the creator when the command stops. Starting it again spawns a fresh set.
The Process Component decides when this runs: its trigger (default: enable and disable) begins it, and Restart as the retrigger means beginning it again lays out or respawns again.
Arrange¶
| Field | Description |
|---|---|
| Subjects | What to arrange: the objects this step moves. |
| Slots | Where to put them: one slot per object. |
| Origin | The object slots are laid out around. Defaults to Context, the object the Process Component sits on. |
| Apply Scale | On: each object takes the slot's scale too. Off: scale is left untouched. |
Spawn¶
| Field | Description |
|---|---|
| Creator | Makes the objects and takes them back. A Pooled Object Creator recycles them across respawns. |
| Count | How many slots to ask for. Masked slot sources may give fewer. |
| Parent | Optional parent for the spawned objects. Empty keeps the creator's parenting. |
| Despawn On End | On: the objects stay while the command runs and go back to the creator when it stops. Off: the step finishes at once and the objects stay. |
| Compose Pose | On: the slot's rotation and scale combine with the pose the creator gave the object. Off: the slot pose replaces it. |
| Slots, Origin, Apply Scale | As for Arrange. |
Monitor¶
Watch a step in the Monitor window to see its slots in the Scene view.
- Arrange has a Layout Now button. It moves the objects right away, in edit mode or play mode, and you can undo it.
- Spawn has Respawn and Despawn All, which restart or end the Process Component in play mode, and Bake To Scene, which creates the objects as real scene objects in edit mode and disables the Process Component.
Source Lifecycle¶
Each run calls Initialize() on the step's subject and slot sources before resolving them. Custom ILayoutSubjectSource / ILayoutSlotSource implementations use it to resolve their Smart* fields (CopiedOnInit mode in particular needs this). Both interfaces provide a default no-op Initialize(), so simple sources don't need to override it.