# unity-technologies/endlessrunnersamplegame architecture

> Architecture diagram of the GitHub repository unity-technologies/endlessrunnersamplegame, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unity-technologies/endlessrunnersamplegame
- Repository: https://github.com/unity-technologies/endlessrunnersamplegame

## Overview

#### Purpose and Runtime
Unity 2019.3 mobile endless-runner sample game. The player selects a character/theme, runs an infinite lane-based track, avoids obstacles, collects currency/power-ups, completes missions, and can purchase content. Runtime is Unity/C# with the Universal/Lightweight Render Pipeline and Unity Addressables. Project launch scene ordering is defined in `ProjectSettings/EditorBuildSettings.asset`; principal scenes are `Assets/Scenes/Start.unity`, `Assets/Scenes/Main.unity`, and `Assets/Scenes/Shop.unity`.

#### Entry and Game-State Orchestration
`GameManager` is the central gameplay coordinator, using explicit state classes for loadout, tutorial, active play, and game-over transitions. UI start actions and scene loading hand off into this state machine; persistent player progress is represented by `PlayerData`.
- `Assets/Scripts/GameManager/GameManager.cs`
- `Assets/Scripts/GameManager/GameState.cs`
- `Assets/Scripts/GameManager/LoadoutState.cs`
- `Assets/Scripts/GameManager/TutorialState.cs`
- `Assets/Scripts/GameManager/GameOverState.cs`
- `Assets/Scripts/PlayerData.cs`
- `Assets/Scripts/LevelLoader.cs`

#### Runner Simulation: Player, Track, and Hazards
The active run connects input-driven character movement/collision to procedurally continued track segments and spawned obstacles. `TrackManager`/`TrackSegment` own the world progression boundary; obstacle subclasses encapsulate behavior variants. `Pooler` supports reuse of runtime objects rather than repeated allocation.
- `Assets/Scripts/Characters/Character.cs`
- `Assets/Scripts/Characters/CharacterInputController.cs`
- `Assets/Scripts/Characters/CharacterCollider.cs`
- `Assets/Scripts/Tracks/TrackManager.cs`
- `Assets/Scripts/Tracks/TrackSegment.cs`
- `Assets/Scripts/Obstacles/Obstacle.cs`
- `Assets/Scripts/Pooler.cs`

#### Progression, Pickups, and Consumables
Collectibles update run/progression state, while consumables provide temporary effects such as magnet, extra life, invincibility, and score multiplier. Character, theme, and consumable databases form content-selection boundaries between runtime gameplay and authored assets.
- `Assets/Scripts/Coin.cs`
- `Assets/Scripts/Consumable/Consumable.cs`
- `Assets/Scripts/Consumable/ConsumableDatabase.cs`
- `Assets/Scripts/Consumable/Types/CoinMagnet.cs`
- `Assets/Scripts/Missions/Missions.cs`
- `Assets/Scripts/Characters/CharacterDatabase.cs`
- `Assets/Scripts/Themes/ThemeDatabase.cs`

#### Content Delivery and Theming
Addressables replaces legacy asset bundles: groups split characters, coins, power-ups, UI, tutorial, and day/night theme resources for build/load management. Theme data points at environment, sky, zones, and obstacle prefab sets; default and nighttime are separate authored content variants.
- `Assets/AddressableAssetsData/AddressableAssetSettings.asset`
- `Assets/AddressableAssetsData/AssetGroups/Characters.asset`
- `Assets/AddressableAssetsData/AssetGroups/Themes.asset`
- `Assets/Bundles/Themes/Default/themeData.asset`
- `Assets/Bundles/Themes/NightTime/themeData.asset`
- `Assets/Bundles/Characters/Cat/character.prefab`

#### UI, Economy, and External Platform Services
Start/menu, mission, HUD, and shop controllers present and mutate player-owned content. Unity IAP is configured through Resources catalog files and handled by `IAPHandler`; ads are surfaced for mission flows. No backend service is evidenced in the supplied tree.
- `Assets/Scripts/UI/MainMenu.cs`
- `Assets/Scripts/UI/MissionUI.cs`
- `Assets/Scripts/UI/Shop/ShopUI.cs`
- `Assets/Scripts/UI/Shop/IAPHandler.cs`
- `Assets/Scripts/UI/AdsForMission.cs`
- `Assets/Resources/IAPProductCatalog.json`

#### Rendering, Audio, and Build Boundaries
The project uses URP assets plus custom world-curving shaders to create the runner’s visual depth. Audio is mixed through Unity’s mixer and controlled by runtime music components. Editor automation builds Addressables/content and player output; target-specific Addressables state exists for Android, Windows, and macOS.
- `Assets/RenderingPipeline.asset`
- `Assets/Scripts/WorldCurver.cs`
- `Assets/Shaders/CurvedRotation.shader`
- `Assets/Scripts/Sounds/MusicPlayer.cs`
- `Assets/Sounds/Mixers/MainMix.mixer`
- `Assets/Editor/BundleAndBuild.cs`

Main entry points: [`Assets/Scripts/GameManager/GameManager.cs`](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/GameManager/GameManager.cs) (Game Manager), [`Assets/Scripts/Tracks/TrackManager.cs`](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Tracks/TrackManager.cs) (Track Progression), [`Assets/Scripts/PlayerData.cs`](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/PlayerData.cs) (Player Data), [`Assets/Scripts/Characters/Character.cs`](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Characters/Character.cs) (Runner Character)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Gameplay Runtime"]
  node_scenes["Launch Scenes<br/>Unity scenes"]
  node_level_loader["Level Loader<br/>scene loader<br/>[LevelLoader.cs]"]
  node_game_manager{{"Game Manager<br/>state coordinator<br/>[GameManager.cs]"}}
  node_game_states["Game States<br/>state classes<br/>[GameState.cs]"]
  node_player_data[("Player Data<br/>persistent progress<br/>[PlayerData.cs]")]
  node_character["Runner Character<br/>player controller<br/>[Character.cs]"]
  node_track["Track Progression<br/>procedural world<br/>[TrackManager.cs]"]
  node_obstacles_pool["Obstacles &amp; Pooling<br/>hazard runtime<br/>[Obstacle.cs]"]
  node_pickups["Pickups &amp; Consumables<br/>progression effects<br/>[Consumable.cs]"]
  node_missions["Missions<br/>progression goals<br/>[Missions.cs]"]
end

subgraph group_content["Content Delivery"]
  node_content_databases[("Content Databases<br/>selection catalogs")]
  node_addressables[("Addressables<br/>content catalog")]
  node_theme_content["Theme Content<br/>authored environments<br/>[themeData.asset]"]
end

subgraph group_ui["UI &amp; Commerce"]
  node_menu_ui["Menu &amp; HUD<br/>UI controllers<br/>[MainMenu.cs]"]
  node_mission_ui_ads["Mission UI &amp; Ads<br/>reward flow<br/>[MissionUI.cs]"]
  node_shop_iap["Shop &amp; IAP<br/>commerce<br/>[IAPHandler.cs]"]
end

subgraph group_presentation["Presentation &amp; Build"]
  node_rendering["URP &amp; World Curving<br/>render pipeline"]
  node_audio["Music &amp; Mixer<br/>audio runtime<br/>[MusicPlayer.cs]"]
  node_build_pipeline["Bundle &amp; Build<br/>editor automation<br/>[BundleAndBuild.cs]"]
end

node_scenes -->|"opens"| node_level_loader
node_level_loader -->|"enters gameplay"| node_game_manager
node_menu_ui -->|"start action"| node_level_loader
node_game_manager -->|"transitions through"| node_game_states
node_game_manager -->|"reads and updates"| node_player_data
node_game_manager -->|"runs"| node_character
node_character -->|"moves through"| node_track
node_track -->|"spawns hazards"| node_obstacles_pool
node_character -->|"collects"| node_pickups
node_pickups -->|"updates progress"| node_player_data
node_missions -->|"tracks goals"| node_player_data
node_mission_ui_ads -->|"presents"| node_missions
node_shop_iap -->|"unlocks content"| node_player_data
node_shop_iap -->|"offers"| node_content_databases
node_content_databases -->|"selects assets from"| node_addressables
node_addressables -->|"loads"| node_theme_content
node_theme_content -->|"configures environment"| node_track
node_rendering -->|"renders"| node_track
node_audio -.->|"responds to state"| node_game_manager
node_build_pipeline -->|"builds content"| node_addressables

click node_scenes "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/ProjectSettings/EditorBuildSettings.asset"
click node_level_loader "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/LevelLoader.cs"
click node_game_manager "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/GameManager/GameManager.cs"
click node_game_states "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/GameManager/GameState.cs"
click node_player_data "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/PlayerData.cs"
click node_character "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Characters/Character.cs"
click node_track "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Tracks/TrackManager.cs"
click node_obstacles_pool "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Obstacles/Obstacle.cs"
click node_pickups "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Consumable/Consumable.cs"
click node_missions "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Missions/Missions.cs"
click node_content_databases "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Characters/CharacterDatabase.cs"
click node_addressables "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/AddressableAssetsData/AddressableAssetSettings.asset"
click node_theme_content "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Bundles/Themes/Default/themeData.asset"
click node_menu_ui "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/MainMenu.cs"
click node_mission_ui_ads "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/MissionUI.cs"
click node_shop_iap "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/Shop/IAPHandler.cs"
click node_rendering "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/RenderingPipeline.asset"
click node_audio "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Sounds/MusicPlayer.cs"
click node_build_pipeline "https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Editor/BundleAndBuild.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_scenes,node_level_loader,node_game_manager,node_game_states,node_player_data,node_character,node_track,node_obstacles_pool,node_pickups,node_missions toneBlue
class node_content_databases,node_addressables,node_theme_content toneAmber
class node_menu_ui,node_mission_ui_ads,node_shop_iap toneMint
class node_rendering,node_audio,node_build_pipeline toneRose
```

## Components

### Gameplay Runtime

Core run orchestration and simulation.

- [Launch Scenes](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/ProjectSettings/EditorBuildSettings.asset): Unity scenes · Start, Main, and Shop are ordered by build settings. · `ProjectSettings/EditorBuildSettings.asset`
- [Level Loader](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/LevelLoader.cs): scene loader · `Assets/Scripts/LevelLoader.cs`
- [Game Manager](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/GameManager/GameManager.cs): state coordinator · Coordinates loadout, tutorial, active run, and game-over transitions. · `Assets/Scripts/GameManager/GameManager.cs`
- [Game States](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/GameManager/GameState.cs): state classes · Explicit loadout, tutorial, and game-over state implementations. · `Assets/Scripts/GameManager/GameState.cs`
- [Player Data](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/PlayerData.cs): persistent progress · `Assets/Scripts/PlayerData.cs`
- [Runner Character](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Characters/Character.cs): player controller · Input, movement, and collision drive the active run. · `Assets/Scripts/Characters/Character.cs`
- [Track Progression](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Tracks/TrackManager.cs): procedural world · Continues track segments and governs world progression. · `Assets/Scripts/Tracks/TrackManager.cs`
- [Obstacles & Pooling](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Obstacles/Obstacle.cs): hazard runtime · Obstacle variants are reused through the object pool. · `Assets/Scripts/Obstacles/Obstacle.cs`
- [Pickups & Consumables](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Consumable/Consumable.cs): progression effects · Coins and temporary power-ups modify run state. · `Assets/Scripts/Consumable/Consumable.cs`
- [Missions](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Missions/Missions.cs): progression goals · `Assets/Scripts/Missions/Missions.cs`

### Content Delivery

Addressable authored game content.

- [Content Databases](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Characters/CharacterDatabase.cs): selection catalogs · Character, theme, and consumable selection boundaries. · `Assets/Scripts/Characters/CharacterDatabase.cs`
- [Addressables](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/AddressableAssetsData/AddressableAssetSettings.asset): content catalog · Groups game assets for build and runtime loading. · `Assets/AddressableAssetsData/AddressableAssetSettings.asset`
- [Theme Content](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Bundles/Themes/Default/themeData.asset): authored environments · Default and nighttime themes define environment and obstacle sets. · `Assets/Bundles/Themes/Default/themeData.asset`

### UI & Commerce

Player-facing menus, missions, and purchases.

- [Menu & HUD](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/MainMenu.cs): UI controllers · Starts runs and presents active gameplay. · `Assets/Scripts/UI/MainMenu.cs`
- [Mission UI & Ads](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/MissionUI.cs): reward flow · Mission interfaces can surface ad-supported flows. · `Assets/Scripts/UI/MissionUI.cs`
- [Shop & IAP](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/UI/Shop/IAPHandler.cs): commerce · Shop purchases use the Unity IAP product catalog. · `Assets/Scripts/UI/Shop/IAPHandler.cs`

### Presentation & Build

Rendering, audio, and build automation.

- [URP & World Curving](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/RenderingPipeline.asset): render pipeline · URP assets and custom shaders create runner visual depth. · `Assets/RenderingPipeline.asset`
- [Music & Mixer](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Scripts/Sounds/MusicPlayer.cs): audio runtime · `Assets/Scripts/Sounds/MusicPlayer.cs`
- [Bundle & Build](https://github.com/unity-technologies/endlessrunnersamplegame/blob/master/Assets/Editor/BundleAndBuild.cs): editor automation · Builds Addressables content and player output. · `Assets/Editor/BundleAndBuild.cs`

## Connections

- Launch Scenes → Level Loader: opens
- Level Loader → Game Manager: enters gameplay
- Menu & HUD → Level Loader: start action
- Game Manager → Game States: transitions through
- Game Manager → Player Data: reads and updates
- Game Manager → Runner Character: runs
- Runner Character → Track Progression: moves through
- Track Progression → Obstacles & Pooling: spawns hazards
- Runner Character → Pickups & Consumables: collects
- Pickups & Consumables → Player Data: updates progress
- Missions → Player Data: tracks goals
- Mission UI & Ads → Missions: presents
- Shop & IAP → Player Data: unlocks content
- Shop & IAP → Content Databases: offers
- Content Databases → Addressables: selects assets from
- Addressables → Theme Content: loads
- Theme Content → Track Progression: configures environment
- URP & World Curving → Track Progression: renders
- Music & Mixer → Game Manager: responds to state
- Bundle & Build → Addressables: builds content
