View: Multi-Page Single Page

Run the demo

The demo is a ready-to-play scene with all four modes. Open Assets/SimpleStates/Scenes/DemoScene and press Play. The landing menu appears first — pick Classic, Ordered, Lights Out, or Trilight, then Play Endless (fresh generated boards) or Play Level Pack (curated levels, in order).

For the pack buttons, assign one StatesPuzzlePack per mode on the StatesDemo component — the buttons show each pack's level count and disable when empty. Endless works with nothing assigned; its dials (sizes, trap policy, and the grid modes' goal — including random pattern targets) sit on the same component.

The slots are per mode only because the menu needs four entry points. A pack itself has no mode: every StatesPuzzle carries its own rules, so one pack can mix Classic, Ordered, Lights Out and Trilight boards freely — useful for a daily set or a campaign that alternates. The HUD names each board from the board itself, so a mixed pack labels every level correctly.

Any pipelineThe board is built from runtime primitives tinted via MaterialPropertyBlock (_BaseColor + _Color), so the demo renders in Built-in, URP, and HDRP — no material conversion.

Controls

Click a switch (or a grid cell) to press it · R reset the board · F auto-solve — the best solution plays back one press at a time (always landing exactly on par); player input locks while it runs, and R cancels mid-playback.

Buttons for the same actions live in the HUD (Reset / Solve / Menu), so the demo is fully playable mouse-only.

Both are plain Unity Canvas + TextMeshPro, built by one-click builders and driven by two small components:

  • StatesMenu — the two-step landing menu. Step 1: mode cards with descriptive subtitles. Step 2: a how-to-play blurb for the chosen mode plus Play Endless / Play Level Pack / Back. It hides on play and returns when a pack finishes or the Menu button is pressed.
  • StatesHud — the in-game card: mode & level label, a goal-aware objective ("Find the press order — turn every state on", "Blackout — turn every light off", "Charge every cell to full bright"…), a live counter (states on / lights on / cells matching the target), presses vs par, difficulty pips, and Reset / Solve / Menu. While auto-solving it swaps to an "Auto-solving…" row with Cancel; on a win it shows a Solved overlay with a par verdict and a Next CTA.

Every label refreshes from StatesDemo / StatesGame state — there is no UI logic inside the game code, so you can delete the Canvas and wire your own UI to the same public surface.

The four boards

  • Classic — a back row of states (they sink and turn green when on) and a front row of switches (they depress and turn gold when pressed). Pressing a switch again un-presses it — classic is pure toggling, so you can always walk a combination back.
  • Ordered — same layout, plus an availability glow: switches whose press would change something right now light up. That includes trap recovery — when a trap turns a state back off, the chain switch you need to re-press glows again.
  • Lights Out — a flat grid of cells; each is both the light (gold = lit, dark = off) and the button. On blackout / pattern goals, small dots mark the cells that must end lit — the target reads directly on the board.
  • Trilight — the same grid with three states: cells tint dark / dim / bright and physically rise a step per level, so the state reads by height as well as color. Some cells need two presses.

Endless mode generates per mode with the dials on StatesDemo: classic states/switches, ordered states/switches (defaults 8/8 with traps required), and grid size + goal for Lights Out and Trilight (default 5×5; the Pattern goal rolls a fresh random target shape every board).

Skin it

  • Prefab slots — drag your own switch and state prefabs onto the Level Renderer; empty slots fall back to primitive cubes, so the scene always runs. Prefabs need a Renderer somewhere in their children (that's what gets tinted) — a collider is added automatically if missing.
  • Colors — the full palette is inspector fields on StatesLevelRenderer: switch normal / pressed / available, state off / on, the grid cell tints (lit / dim / dark), the target-marker color, and the Trilight per-level rise distance.
  • Layout — spacing, row gap, state-drop distance, lerp speed, and the Lights Out cell spacing are all dials on the same component.
  • SoundStatesBeeper synthesizes its clicks, blips, and the win jingle procedurally (no audio files). Replace it: subscribe your own handler to StatesGame's events and play AudioClips instead.

The parts

ComponentRole
StatesDemoFlow: mode + endless/pack choice, level advance, the four pack slots, per-mode generation dials, UI blip passthrough.
StatesGameThe referee: presses, gates, board state, win detection, auto-solve. All events live here.
StatesLevelRendererBuilds the 3D board; prefab slots, palette, layout dials.
StatesSwitchHandleTags each clickable switch/cell with its index.
StatesInputMouse raycast presses + the R / F keys (Input System).
StatesMenu / StatesHudThe Canvas landing menu and in-game HUD.
StatesBeeperProcedural SFX.

Rebuild / your own scene

The demo scene ships pre-built. To rebuild it from nothing (or into an existing scene):

  • Window ▸ Living Failure ▸ Simple States ▸ Build Demo Scene — everything in one click: board rig (game, renderer, input, beeper, camera, light) plus the Canvas menu and HUD, fully wired.
  • … ▸ Demo Setup ▸ Create Demo Menu / Create Demo HUD — just the Canvas pieces, for dropping the demo UI into your own scene.

For a minimal scene of your own you need four things: a StatesGame + StatesLevelRenderer pair, a StatesInput (or your own input calling PressSwitch), and a camera. Feed LoadLevel any puzzle — generated at runtime or from a saved asset.

EventSystemThe Canvas builders create an EventSystem (with the Input System UI module) if the scene has none — if UI clicks ever do nothing in your own scene, check one exists.