Add a fully self-contained in-game shop to your project — scrollable item list, buy buttons, balance display, and sound effects. Wire purchase events to any game effect. No UI setup required.
Three steps and the store is playable. Everything else — UI, audio, persistence — is optional.
GameStoreManager component. Keep it on its own object — not on the player or an NPC.GameCollectionManager into the Currency Source slot. The store reads and deducts from this manager's value automatically. Students collect currency by wiring pickups to GameCollectionManager.Increment() as usual.B by default and shows a fully styled panel with buy buttons and a live balance display.PlayerController.EnableDoubleJump(), GameHealthManager.Heal(25), Spawner.SetActive(true). This event also re-fires when a persistent item is restored on scene load — so game state is always correct.Each item in the list is independently configured. Give it a name, a price, and wire On Purchased to whatever should happen when the player buys it.
| Field | Default | What it does |
|---|---|---|
| Item Name | Item | Display name shown in the store row. |
| Icon | none | Optional sprite shown on the left of the row. |
| Price | 10 | Cost deducted from the Currency Source on each purchase. |
| Max Purchases | 0 | 0 = unlimited (consumable). 1 = one-time unlock. 3 = up to three times. The Buy button greys out when the limit is reached. |
| Persist Purchase | true | Remember the purchase count across scene loads. Leave on for permanent unlocks and upgrades. Turn off for consumables like health packs — they don't need to be remembered. |
| On Purchased | — | Fires on each successful purchase. Wire to gameplay effects only — sounds and UI are automatic. |
| On Cannot Afford | — | Fires when the player tries to buy but lacks the funds. Wire to a shake, flash, or audio cue if desired. |
Max Purchases: 3, Persist Purchase: on), On Purchased fires twice when the scene reloads — applying both upgrades correctly. You don't need to track anything manually.Choose between a global key shortcut or event-driven opening for a walk-up shopkeeper in game space.
B) from anywhere to toggle the store open and closed. Good for inventory-style shops accessible at any time.
OpenStore() is called from a UnityEvent. Place the shopkeeper anywhere in the world — the player must walk up to buy.
InputTriggerZone to a collider near the NPCGameStoreManager.OpenStore()GameStoreManager.CloseStore() (optional — the ✕ button also closes)CharacterControllerFP has its look input disabled and cursor released. CharacterControllerCC has movement disabled. Both are restored when the store closes.Items with Persist Purchase enabled remember how many times they've been bought — even when the scene changes. The store restores game state automatically on load.
When a scene is loaded via GameSceneManager.RestartScene() — for example after the player dies — the On Restart setting controls what happens to purchase history.
| On Restart | Behavior |
|---|---|
| Keep Value default | Purchase history survives death. The player keeps the double jump they worked to unlock — recommended for permanent upgrades. |
| Reset To Default | All purchase counts clear on restart. Use for roguelike-style runs where you lose everything on death. |
GameSceneManager.RestartScene("Level1") for death/failure restarts — this is what triggers the On Restart behavior. Use LoadScene("Level2") for progression — purchase history always carries forward regardless of On Restart setting.Copy these configurations directly into the Store Items list.
The defaults work for most setups. Only the Currency Source and Store Items require configuration.
| Field | Default | What it does |
|---|---|---|
| Currency Source | — | Required. The GameCollectionManager whose value is spent on purchases. |
| Open Mode | Key | Key: toggle with a keypress. Event Only: open/close via UnityEvents. |
| Open / Close Key | B | Key used when Open Mode is Key. Hidden when Event Only is selected. |
| FP Controller | none | Optional. Disables look input and releases cursor while the store is open. |
| CC Controller | none | Optional. Disables movement while the store is open. |
| One Per Visit | false | If on, each item can only be bought once per store opening, regardless of Max Purchases. |
| On Restart | Keep Value | What happens to persistent purchase counts when RestartScene() is called. |
| Audio Manager | none | Optional GameAudioManager for music switching when the store opens and closes. |
| Store Music | none | Music to play while the store is open. Requires Audio Manager. |
| Previous Music | none | Music to restore on close. Requires Audio Manager. |
| Purchase Sound | none | Plays on each successful purchase via the assigned Audio Source. |
| Can't Afford Sound | none | Plays when the player tries to buy but cannot afford the item. |
| Show UI | true | Creates a self-contained store panel at runtime. Disable if you want to build your own UI and call PurchaseItem(index) manually. |
| Store Title | STORE | Text shown at the top of the panel. |
| Event | When it fires |
|---|---|
| onStoreOpened | Store panel becomes visible. Wire to a pause overlay, background dim, or audio trigger. |
| onStoreClosed | Store panel is hidden. Wire to resume gameplay elements. |
| onAnyPurchase | Fires whenever any item is successfully purchased. Wire to a shared feedback effect. |