Build fast, scalable mobile and WebGL games with a clean architecture, Addressables, and a lightweight service layer.
Target audience: Unity developers building mobile (iOS/Android) and WebGL games who want a solid starting point with best practices.
1) Clone
git clone https://github.com/CoderGamester/Core-Game.git
cd Core-Game
2) Open in Unity Hub (Unity 6000.0.55f1 recommended)
3) Generate Addressables settings
4) Configure UI (optional)
UiConfigs.asset
(Project search or Tools > Select UiConfigs.asset if available)5) Open the โBootโ Scene and Play
Constants.Scenes.BOOT
(boots into Main additively)6) Run the sample and inspect the flow
The entrypoint Main
(Assets/Src/Main.cs
) wires services and starts the game state machine.
Key responsibilities of Main
:
Installer
GameStateMachine
Example (excerpt from Main.cs
):
var installer = new Installer();
installer.Bind<IMessageBrokerService>(new MessageBrokerService());
installer.Bind<ITimeService>(new TimeService());
installer.Bind<GameUiService, IGameUiServiceInit, IGameUiService>(new GameUiService(new UiAssetLoader()));
installer.Bind<IPoolService>(new PoolService());
installer.Bind<ITickService>(new TickService());
installer.Bind<ICoroutineService>(new CoroutineService());
installer.Bind<AssetResolverService, IAssetResolverService, IAssetAdderService>(new AssetResolverService());
installer.Bind<ConfigsProvider, IConfigsAdder, IConfigsProvider>(new ConfigsProvider());
installer.Bind<DataService, IDataService, IDataProvider>(new DataService());
var gameServices = new GameServicesLocator(installer);
installer.Bind<IGameServicesLocator>(gameServices);
_stateMachine = new GameStateMachine(installer);
Lifecycle hooks (excerpt):
private void OnApplicationPause(bool isPaused)
{
if (isPaused)
{
_dataService.SaveAllData();
_services.AnalyticsService.FlushEvents();
}
_services.MessageBrokerService.Publish(new ApplicationPausedMessage { IsPaused = isPaused });
}
State and logic boundaries are orchestrated by GameServicesLocator
, GameLogicLocator
, and GameStateMachine
instances.
Assets/
Addressables/
โ runtime-loadable assets (configs, scenes, prefabs, UI)
Scenes/
โ scenes to be loaded (often additively) at runtimePrefabs/
โ UI and gameplay prefabs (e.g., Compliance Screen)Libs/
โ third-party librariesResources/
โ avoid for game content; reserved for Unity defaults/pluginsSrc/
โ gameplay code and composition roots (e.g., Main.cs
, BootSplashscreen.cs
)
Cheats/
โ developer cheats and test toggles (e.g., SROptions.Cheats.cs
)Commands/
โ commands to trigger game logic actions (e.g., AcceptComplianceCommand.cs
, RestartGameCommand.cs
)Configs/
โ ScriptableObject config definitions (e.g., DataConfigs.cs
, GameConfigs.cs
, SceneAssetConfigs.cs
)Data/
โ persistent data models (e.g., AppData.cs
, PlayerData.cs
) saved via IDataService
Editor/
โ editor-only tools (asset/sheet importers, utilities)Ids/
โ strongly-typed IDs and auto-generated Addressable IDs (AddressableId.cs
, GameId.cs
, SceneId.cs
)Logic/
โ domain game logic and facades (GameLogicLocator.cs
, plus Client/
and Server/
folders)Messages/
โ message types/events published via IMessageBrokerService
(e.g., ApplicationStateMessages.cs
)Presenters/
โ UI presenters (MVP) for all UI screens managed by the โGameUiServiceโ (e.g., MainHudPresenter.cs
, MainMenuPresenter.cs
)Services/
โ game-specific services/adapters (GameServicesLocator.cs
, analytics helpers, UI service, world refs)StateMachines/
โ game flow states and orchestrator (e.g., GameStateMachine.cs
, InitialLoadingState.cs
)Utils/
โ constants and small helpers (Constants.cs
)ViewControllers/
โ base/entity view controllers handled by the Presenters (ViewControllerBase.cs
, EntityViewController.cs
)Views/
โ view MonoBehaviours (e.g., TimerView.cs
)Packages/
โ Package Manager manifest and lockProjectSettings/
โ Unity project settings and versionWebGL_Build/
โ example built WebGL output and template filesRationale: prioritize Addressables over Resources/
to reduce initial payloads and enable content updates.
Declared in Packages/manifest.json
(selected):
com.gamelovers.services
โ service locator and installer utilitiescom.gamelovers.statechart
โ state machinecom.gamelovers.uiservice
โ UI service scaffoldingcom.gamelovers.assetsimporter
โ Addressables import helperscom.gamelovers.configsprovider
โ static config providercom.gamelovers.dataextensions
โ extensions and data containerscom.gamelovers.googlesheetimporter
โ Google Sheets data importcom.cysharp.unitask
โ async/await for Unity without allocationscom.acegikmo.mathfs
โ math helpersSee also:
AddressableId
helpersExample usage:
// Example from docs
AddressableId.Addressables_Configs_DataConfigs.GetConfig().Address;
Notes
Resources/
for gameplay contentBoot
scene contains BootSplashScreen
and is the initial sceneMain
scene hosts Main
(composition root) and gameplay entry1) Build Settings
WebGL_Build/
2) Addressables
3) Hosting
WebGL_Build/
)Tips
OnApplicationQuit
is not called; this project publishes quit on pause for WebGL1) Build Settings
2) Addressables
3) Analytics/Diagnostics
Resources/
IPoolService
)UniTask
) during splash/bootReimport All
if neededUNITY_IOS
; ensure related package/capabilities only for iOS buildsgit checkout -b feature/AmazingFeature
)git commit -m "Add some AmazingFeature"
)git push origin feature/AmazingFeature
)https://codergamester.github.io/Core-Game/WebGL_Build/