Skip to content

Archived on 2026-10-24. This is a historical implementation note, not current setup instructions or an active task list. Original claims, code examples, file paths, and completion statements have not all been revalidated. Use the current documentation and issue register for maintenance decisions.

Quit Confirmation System Implementation

Overview

The quit confirmation system provides a safety mechanism when players try to exit the game from the main menu. Instead of immediately quitting, the system shows a confirmation page, preventing accidental game exits.

Implementation Details

Components

1. MenuController.cs

The main controller that manages the quit confirmation logic.

Key Fields: - QuitConfirmationPage (Page): The page to display when showing quit confirmation - PageStack (Stack<Page>): Manages the navigation stack

Key Methods:

PopPage()

Handles back button navigation with quit confirmation logic: - Checks if currently on quit confirmation page → Returns to main menu - Checks if on root page → Shows quit confirmation - Otherwise → Performs normal page popping

PopPageInternal()

Internal method that performs the actual page popping logic: - Exits the current page - Enters the previous page (if ExitOnNewPagePush is true) - Updates button text - Triggers page popped event

ShowQuitConfirmation()

Displays the quit confirmation page: - Exits the current page (if ExitOnNewPagePush is true) - Enters the quit confirmation page - Pushes it onto the page stack

UpdateBackQuitText()

Updates the back/quit button text based on current page: - Root page → Shows "Quit" - Quit confirmation page → Shows "Quit" - Other pages → Shows "Back"

Workflow

Scenario 1: Normal Navigation

  1. Player presses back on a sub-page
  2. PopPage() is called
  3. Page is popped and user navigates back
  4. Button text updates to "Back"

Scenario 2: Quit Attempt from Main Menu

  1. Player presses back on the root (main menu) page
  2. PopPage() detects we're on root page
  3. ShowQuitConfirmation() is called
  4. Quit confirmation page is pushed onto stack
  5. Button text updates to "Quit"

Scenario 3: Cancel Quit

  1. Player presses back while on quit confirmation page
  2. PopPage() detects we're on quit confirmation page
  3. PopPageInternal() is called
  4. Quit confirmation page is popped
  5. Returns to main menu
  6. Button text updates to "Quit"

Scenario 4: Confirm Quit

  1. Player presses quit button on quit confirmation page
  2. QuitGame() is called
  3. Application.Quit() terminates the game

Setup Instructions

Unity Editor Setup

  1. Create the Quit Confirmation Page
  2. Create a new GameObject with a Page component
  3. Set up UI elements (confirmation message, quit button, cancel button)
  4. Configure Page Elements for animations
  5. Mark appropriate settings (Entry/Exit animations, etc.)

  6. Connect the Page to MenuController

  7. Select the MenuController GameObject in your scene
  8. In the Inspector, find the new QuitConfirmationPage field
  9. Drag your quit confirmation page GameObject into this field

  10. Button Configuration

  11. On your quit button, add an onClick event
  12. Call MenuController.instance.QuitGame()
  13. The back button is handled automatically via the Update() method

  14. Localization

  15. Ensure "Quit" string exists in your localization table
  16. TableReference: "MainMenu"
  17. TableEntryReference: "Quit"

Key Features

✅ Safety: Prevents accidental game exits ✅ User-Friendly: Clear confirmation before quitting ✅ Cancel Option: Players can return to main menu ✅ Consistent UI: Uses existing page system and animations ✅ Localization Support: Button text is localized ✅ Input Support: Works with both keyboard and controller

Code Flow Diagram

User presses Back/Pause
        ↓
MenuController.Update() detects input
        ↓
PopPage() is called
        ↓
Is it QuitConfirmationPage?
  ├─ Yes → PopPageInternal() → Return to menu
  └─ No → Continue
        ↓
Is it Root Page?
  ├─ Yes → ShowQuitConfirmation()
  │       ├─ Exit current page
  │       ├─ Enter quit confirmation page
  │       └─ Update button text to "Quit"
  └─ No → PopPageInternal() → Normal navigation
        ↓
Update button text

Notes

  • The quit confirmation page should have a Page component configured with appropriate animations
  • The back button text will show "Quit" both on the main menu and on the quit confirmation page
  • The QuitGame() method simply calls Application.Quit(), which works in standalone builds
  • In the Unity Editor, Application.Quit() does nothing - you'll need to use Play Mode Exit or Editor testing methods
  • The system supports up to 2 players with separate input detection

Future Enhancements

Possible improvements to consider: - Add sound effects for quit confirmation - Add visual feedback when hovering over quit button - Add statistics tracking for quit events - Add "Don't show again" option for experienced players - Add custom quit confirmation messages based on game state

Troubleshooting

Issue: Quit confirmation doesn't appear - Check if QuitConfirmationPage is assigned in MenuController - Verify the quit confirmation page has a Page component - Check Unity Console for error messages

Issue: Button text doesn't update - Verify localization strings are set up correctly - Check if MenuView.instance is not null - Ensure UpdateBackQuitText() is being called

Issue: Game doesn't quit - Note: Application.Quit() doesn't work in Unity Editor - Test with a standalone build to verify quit functionality - Check for any error messages in the console