logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityGameModeService

    Unity MonoBehaviour implementation of IGameModeService.

    Inheritance
    object
    UnityGameModeService
    Implements
    IGameModeService
    IService
    IFoundationSettings
    Namespace: Serenity.GameMode.Infrastructure.Services
    Assembly: Serenity.UnityGameMode.Infrastructure.dll
    Syntax
    public class UnityGameModeService : MonoBehaviour, IGameModeService, IService, IFoundationSettings
    Remarks

    Manages game mode state and coordinates transitions between Menu, Game, and Pause modes. Handles input routing, time scale, UI changes, and additive scene loading during mode transitions.

    Constructors

    UnityGameModeService()

    Declaration
    public UnityGameModeService()

    Fields

    LOG_CATEGORY

    Declaration
    protected const string LOG_CATEGORY = "GameModeService"
    Field Value
    Type Description
    string

    _currentMode

    Declaration
    protected GameMode _currentMode
    Field Value
    Type Description
    GameMode

    _eventDispatcher

    Declaration
    protected IEventDispatcherService _eventDispatcher
    Field Value
    Type Description
    IEventDispatcherService

    _gameWrapper

    Declaration
    protected GameObject _gameWrapper
    Field Value
    Type Description
    GameObject

    _gameplayReadinessGate

    Declaration
    protected IGameplayReadinessGate _gameplayReadinessGate
    Field Value
    Type Description
    IGameplayReadinessGate

    _gameplaySceneName

    Declaration
    protected string _gameplaySceneName
    Field Value
    Type Description
    string

    _guid

    Declaration
    protected string _guid
    Field Value
    Type Description
    string

    _id

    Declaration
    protected string _id
    Field Value
    Type Description
    string

    _isGameplaySceneLoaded

    Tracks whether the gameplay scene is currently loaded.

    Declaration
    protected bool _isGameplaySceneLoaded
    Field Value
    Type Description
    bool

    _isSceneTransitioning

    Whether a scene loading/unloading operation is in progress.

    Declaration
    protected bool _isSceneTransitioning
    Field Value
    Type Description
    bool

    _loadingOverlay

    Declaration
    protected IGameplayLoadingOverlayView _loadingOverlay
    Field Value
    Type Description
    IGameplayLoadingOverlayView

    _logService

    Declaration
    protected ILogService _logService
    Field Value
    Type Description
    ILogService

    _menuService

    Declaration
    protected IMenuService _menuService
    Field Value
    Type Description
    IMenuService

    _pauseAction

    Declaration
    protected InputAction _pauseAction
    Field Value
    Type Description
    InputAction

    _pauseStrategy

    Declaration
    protected IPauseStrategy _pauseStrategy
    Field Value
    Type Description
    IPauseStrategy

    _playerInputService

    Declaration
    protected IPlayerInputService _playerInputService
    Field Value
    Type Description
    IPlayerInputService

    _previousMode

    Declaration
    protected GameMode _previousMode
    Field Value
    Type Description
    GameMode

    _sceneContentContainer

    Container for GameObjects loaded from the gameplay scene.

    Declaration
    protected GameObject _sceneContentContainer
    Field Value
    Type Description
    GameObject

    _settings

    Declaration
    protected IGameModeSettingsDefinition _settings
    Field Value
    Type Description
    IGameModeSettingsDefinition

    _viewRouter

    Declaration
    protected IViewRouter _viewRouter
    Field Value
    Type Description
    IViewRouter

    Properties

    CurrentMode

    Declaration
    public GameMode CurrentMode { get; }
    Property Value
    Type Description
    GameMode

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    IsPaused

    Declaration
    public bool IsPaused { get; }
    Property Value
    Type Description
    bool

    IsSceneTransitioning

    Whether a scene transition is currently in progress.

    Declaration
    public bool IsSceneTransitioning { get; }
    Property Value
    Type Description
    bool

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    PreviousMode

    Declaration
    public GameMode PreviousMode { get; }
    Property Value
    Type Description
    GameMode

    Methods

    EnterGame()

    Declaration
    public virtual void EnterGame()

    EnterMenu()

    Declaration
    public virtual void EnterMenu()

    InitializeService(IGameModeSettingsDefinition, IPauseStrategy, IPlayerInputService, IMenuService, IEventDispatcherService, ILogService, GameObject, string, IGameplayReadinessGate, IGameplayLoadingOverlayView, IViewRouter)

    Initializes the game mode service with required dependencies.

    Declaration
    public virtual void InitializeService(IGameModeSettingsDefinition settings, IPauseStrategy pauseStrategy, IPlayerInputService playerInputService, IMenuService menuService, IEventDispatcherService eventDispatcher, ILogService logService, GameObject gameWrapper, string gameplaySceneName, IGameplayReadinessGate gameplayReadinessGate = null, IGameplayLoadingOverlayView loadingOverlay = null, IViewRouter viewRouter = null)
    Parameters
    Type Name Description
    IGameModeSettingsDefinition settings

    The game mode settings definition.

    IPauseStrategy pauseStrategy

    The pause strategy for time scale manipulation.

    IPlayerInputService playerInputService

    The player input service for action map switching.

    IMenuService menuService

    The menu service for showing/hiding menus.

    IEventDispatcherService eventDispatcher

    The event dispatcher service for dispatching signals.

    ILogService logService

    The log service for logging.

    GameObject gameWrapper

    The GameWrapper GameObject for parenting loaded scene content.

    string gameplaySceneName

    The name of the gameplay scene to load additively.

    IGameplayReadinessGate gameplayReadinessGate

    Optional gate controlling when gameplay content becomes visible. Gameplay-side code should call MarkReady() once its initialization is complete.

    IGameplayLoadingOverlayView loadingOverlay

    Optional view responsible for rendering the fullscreen loading overlay while gameplay initializes.

    IViewRouter viewRouter

    SetMode(GameMode)

    Declaration
    public virtual void SetMode(GameMode mode)
    Parameters
    Type Name Description
    GameMode mode

    TogglePause()

    Declaration
    public virtual void TogglePause()

    Implements

    IGameModeService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved