Example

Score & Collection System

Build a working coin counter, score display, and threshold event — step by step. GameCollectionManager tracks a number, fires events when it crosses thresholds, and can show its own UI with a single checkbox.

Coins increment on collect
Score displays on screen
Win condition at threshold
Collectibles are just tagged triggers

Step by Step

Setting up the collection system

Three objects. One wire. That's the minimum viable collection system.

  1. 1
    Create a Manager object and add GameCollectionManager
    Create an empty GameObject, name it CollectionManager. Add the GameCollectionManager component. Set Label Prefix to something like Coins: . Enable Show UI — a text display will appear automatically at runtime, no Canvas needed.
  2. 2
    Create a collectible — a tagged trigger
    Create a sphere (or use any mesh). Add a Collider and check Is Trigger. Set its Tag to Collectible (or any tag you choose — it just needs to be consistent). Add an InputTriggerZone component to the player, set its Trigger Object Tag to match.
  3. 3
    Wire the trigger to the manager
    Select the player (or the object with InputTriggerZone). In the On Enter event: drag in CollectionManager, choose function GameCollectionManager → Increment(). The default increment is 1 — pass a specific int if you need a different value. Also wire On Enter → the collectible's SetActive(false) to hide it on collect.
  4. 4
    Duplicate the collectible to place more
    Select the configured collectible and press Ctrl+D. Reposition. The duplicate keeps its tag and collider. Remember: if you save it as a prefab, you lose the cross-scene event wiring — but for collectibles that only call SetActive(false) on themselves, the prefab works fine.

Complete wiring for this example


Threshold Events

Fire an event when the score reaches a value

Thresholds let you react when the count crosses a number — in either direction. This is how you build win conditions, difficulty spikes, and bonus triggers.

  1. 1
    Add a threshold on GameCollectionManager
    In the Inspector, find the Thresholds list and add an entry. Set the Value to your target (e.g. 10 for collecting 10 coins).
  2. 2
    Wire On Crossed Up
    The onCrossedUp event fires once when the value goes from below to at-or-above the threshold. Wire it to whatever should happen — GameStateManager.Victory() for a win, ActionAutoSpawner.StartSpawning() to trigger a wave, or ActionPlaySound.PlaySound() for a fanfare.
  3. 3
    Optional: On Crossed Down
    onCrossedDown fires when the value drops back below the threshold. Useful for resources that can be spent — e.g. player uses 10 coins, drops below threshold, and a UI warning appears.
💡
Thresholds fire once per crossing
If the value crosses the threshold, drops back, and crosses again, onCrossedUp fires again. This is intentional — it lets thresholds work for both one-time win conditions and repeating bonus triggers. Set Max Value if you want to cap the score.

Displaying the Value

Two ways to show score on screen

Use one or the other — not both on the same manager at once.

Option A — Zero setup
Enable Show UI
Check Show UI on GameCollectionManager. A Canvas and text label are created automatically at runtime. Set Label Prefix for the text, Text Position to place it. Enable Show Bar + set Max Value to also get a progress bar.

Best for: Prototyping, quick setup, when you don't need custom styling.
Option B — Full control
Wire to GameUIManager
Add GameUIManager to a manager object. Wire GameCollectionManager.onValueChanged → GameUIManager.UpdateScore(int). GameUIManager creates its own styled Canvas with score, health, timer, and inventory slots.

Best for: When you want a consistent HUD across all managers.
⚠️
Don't enable Show UI and wire GameUIManager on the same manager
Both will run simultaneously and create overlapping displays. Choose one approach per manager and stick with it.

Key Inspector fields

FieldWhat it doesNotes
Label PrefixText before the number (e.g. "Coins: ")Include trailing space
Show UICreates a Canvas text display automaticallyDisable if using GameUIManager
Text PositionScreen position of the text (top-left origin)Use editor preview to position
Show BarAdds a progress bar below the textRequires Max Value > 0
Max ValueCap on the value; bar fills to this0 = no cap, bar disabled
ThresholdsList of values that fire events on crossingAdd multiple for multi-stage goals
Persist Across ScenesCarries the value across scene loadsPut in first scene only