How unity-technologies/endlessrunnersamplegame works
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: GameManager.cs Game Manager · TrackManager.cs Track Progression · PlayerData.cs Player Data · Character.cs Runner Character
Components 19
Gameplay Runtime
Core run orchestration and simulation.
- Launch Scenes · Start, Main, and Shop are ordered by build settings.
ProjectSettings/EditorBuildSettings.asset - Level Loader
Assets/Scripts/LevelLoader.cs - Game Manager · Coordinates loadout, tutorial, active run, and game-over transitions.
Assets/Scripts/GameManager/GameManager.cs - Game States · Explicit loadout, tutorial, and game-over state implementations.
Assets/Scripts/GameManager/GameState.cs - Player Data
Assets/Scripts/PlayerData.cs - Runner Character · Input, movement, and collision drive the active run.
Assets/Scripts/Characters/Character.cs - Track Progression · Continues track segments and governs world progression.
Assets/Scripts/Tracks/TrackManager.cs - Obstacles & Pooling · Obstacle variants are reused through the object pool.
Assets/Scripts/Obstacles/Obstacle.cs - Pickups & Consumables · Coins and temporary power-ups modify run state.
Assets/Scripts/Consumable/Consumable.cs - Missions
Assets/Scripts/Missions/Missions.cs
Content Delivery
Addressable authored game content.
- Content Databases · Character, theme, and consumable selection boundaries.
Assets/Scripts/Characters/CharacterDatabase.cs - Addressables · Groups game assets for build and runtime loading.
Assets/AddressableAssetsData/AddressableAssetSettings.asset - Theme Content · 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 · Starts runs and presents active gameplay.
Assets/Scripts/UI/MainMenu.cs - Mission UI & Ads · Mission interfaces can surface ad-supported flows.
Assets/Scripts/UI/MissionUI.cs - Shop & IAP · Shop purchases use the Unity IAP product catalog.
Assets/Scripts/UI/Shop/IAPHandler.cs
Presentation & Build
Rendering, audio, and build automation.
- URP & World Curving · URP assets and custom shaders create runner visual depth.
Assets/RenderingPipeline.asset - Music & Mixer
Assets/Scripts/Sounds/MusicPlayer.cs - Bundle & Build · Builds Addressables content and player output.
Assets/Editor/BundleAndBuild.cs
Connections 20
- 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