<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Navigation
</aside>
<aside> 💡 Game systems are accessed through static controllers. Most of them are created by an init module, so they are ready when the Game scene starts.
</aside>
Call the static API instead of searching for objects in the scene.
| Controller | Role | Common calls |
|---|---|---|
| SaveController | Loads and saves data. | GetSaveObject<T>(key), MarkAsSaveIsRequired(), Save() |
| UIController | Shows and hides UI pages. | ShowPage<T>(), HidePage<T>(), GetPage<T>(), IsDisplayed<T>() |
| Overlay | Full screen fade used between states. | Overlay.Show(duration, callback), Overlay.Hide(duration) |
| LogManager | Logging with categories. | LogManager.Log(message, category) |
| Controller | Role | Common calls |
|---|---|---|
| CurrencyController | Currency balances. | Get, Add, Substract, HasAmount |
| AudioController | Sounds and music. | PlaySound, GetClip, PlayLoopingSound |
| ParticlesController | Particle effects by name. | PlayParticle(name) |
| UpgradesController | Active upgrades of the current level. | LoadUpgrades, GetUpgrade<T> |
| AdsManager | Advertisement. | See the Advertisement module doc. |
| Tween | Tweens and delayed calls. | Tween.DelayedCall, Tween.DoFloat |
| Controller | Role | Common calls |
|---|---|---|
| GameController | Runs the loop of one level. Not static. | See ‣. |
| ProgressionController | Passes upgrades of a Level to UpgradesController and exposes the multipliers. |
LoadLevel, LauncherPowerMultiplier, VehicleEfficiencyMultiplier, IncomeMultiplier |
| LevelSelectionController | Saves the selected level and the highest reached level. | GetSelectedLevelId, SetSelectedLevelId, MarkLevelReached |
| CameraController | Switches the camera states. | SetState, SetRunTarget, SetRunCamera, FreezeRun |
| BoosterController | Active boosters. | Activate, IsActive, DeactivateAll, OnBoosterActivated |
| PreRunModifierController | Modifiers chosen before the run. | Activate, IsActive, GetRemainingTime, GetBonusPercent |
| RunStateController | Resets world objects that changed during a run. | MarkDirty, ResetRun |
| RunCoinsController | Coins collected during the current run. | Add, AddCredited, ResetRun |
| LevelMusicController | Level music. | Play(clip) |
| BreakablePropController | Breakable props of the level. | Used by breakable props. |
A controller created by an init module is a regular class with a static instance. The module creates it in InitAsync and releases it in Unload. See the BoosterInitModule code:
public override IEnumerator InitAsync(GameObject owner)
{
boosterController = new BoosterController(boosterDatabase);
yield break;
}
FeatureNameController with a static public API.FeatureNameInitModule and register it with [RegisterModule("Name")].FeatureNameSave : ISaveObject when the feature needs persistence.FeatureNameDatabase : ScriptableObject when the feature needs configuration data.Objects of a level scene use three interfaces to take part in the run:
| Interface | Purpose |
|---|---|
IRunStateObject |
The object calls RunStateController.MarkDirty when its state changes and returns to the initial state in ResetState(). The reset runs without a scene reload. |
IChunkActivatable |
The object is enabled only while the character is near it. See World Objects. |
ISceneSaveObject |
The object stores save data that belongs to one Level, for example a collected pickup or the record wall. InitSave(levelId) is called once per level load with the id of the Level, because one scene can be reused by several Level assets. |