<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

🏠 Home Page

Getting Started

Architecture

Level System

Characters & Vehicles

Run Mechanics

World Objects

Boosters & Modifiers

Progression & Economy

UI

Save & Debugging

Modules

Publishing

Reference

πŸ’° Monetization (Ads & IAP)

<aside> πŸ’‘ The whole game UI lives in the Game scene as pages. Each page is a canvas with a UIPage component. UIController from Watermelon Core shows and hides the pages.

</aside>

Subsystems

ui-main-canvas.png

Pages of the game

Page prefabs are stored in Assets/Project Files/Game/Prefabs/UI/Canvas.

Page Class Role
UI Start Screen UIStartScreen Pre-run screen. Upgrade slots, pre-run modifier button, progression, settings and no-ads buttons, coin and gem balances, the tap to start area.
UI Launch UILaunch Aim phase. Hosts the aim input panel for the launcher of the level, the pull indicator and the Back button.
UI Game UIGame Run HUD. Contains RunHUD, the active booster HUD and the Restart button.
UI Run Result UIRunResult End of a run. See β€£.
UI Level Complete UILevelComplete End of a level.
UI Progression UIProgression List of levels with the unlock animation. See β€£.
UI Pre Run Modifiers UIPreRunModifiersPopup Popup with the three modifier slots. See β€£.
UI Game Settings UISettings Settings popup. See β€£.
UI No Ads Pop Up UINoAdsPopUp Popup with the remove ads purchase.

Page flow

Start Screen ──tap──▢ Launch ──release──▢ Game ──end──▢ Run Result ──continue──▢ Start Screen
     β”‚                  β”‚                   └─finish─▢ Level Complete ──continue──▢ next level
     β”œβ”€ Progression     └─ Back ─▢ Start Screen
     β”œβ”€ Pre Run Modifiers (popup)
     β”œβ”€ Settings (popup)
     └─ No Ads (popup)

GameController shows the pages with UIController.ShowPage<T>() and subscribes to the page events (OnTapToStart, OnBackPressed, OnRestartPressed, OnContinuePressed).

UIController API

Method Description
ShowPage<T>() Shows a page and runs OnShow.
HidePage<T>(callback) Hides a page and runs OnHide.
GetPage<T>() Returns the page of the type.
HasPage<T>() Checks that the page exists.
IsDisplayed<T>() Checks that the page is shown.
IsPopupOpened Checks whether any popup is open.
PageOpened, PageClosed, PopupOpened, PopupClosed Events.

Startup order

  1. GameController.Awake calls uiController.Init(). It caches the references and discovers the pages.
  2. The particles controller is initialized.
  3. uiController.InitPages() calls Init() on every page. Pages can use all modules here.

UIPage lifecycle

Member Description
Init() Abstract. Bind buttons and subscribe to events.
OnShow() Abstract. Play the show animation and call NotifyOpened() at the end.
OnHide() Abstract. Play the hide animation and call NotifyClosed() at the end.
OnUnload() Optional cleanup.
IsPopup true for a popup. UIController tracks open popups.
IsPausePopup true to set Time.timeScale to 0 while the popup is open. Requires IsPopup.

Pages use the animation helpers UIFadeAnimation and UIScaleAnimation. A pause popup must run its animations on unscaled time.

Safe area

Register the main rect transform of every page with SafeAreaAdapter.RegisterRectTransform(safeAreaRectTransform) in Init, so the content stays inside the safe area of the device.

Overlay

Overlay.Show(duration, callback) fades the screen to black and calls the callback. Overlay.Hide(duration) fades it back. GameController uses it to hide the reset of the run and the load of the next level.

Start screen events

UIStartScreen raises OnTapToStart. It also refreshes the No Ads button when AdsManager.ForcedAdDisabled fires, plays the coin cloud with the run reward and resets the gem offers of the upgrade slots at every new run.