Class UnityGameModeService
Unity MonoBehaviour implementation of IGameModeService.
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()
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 void EnterGame()
EnterMenu()
Declaration
public void EnterMenu()
InitializeService(IGameModeSettingsDefinition, IPauseStrategy, IPlayerInputService, IMenuService, IEventDispatcherService, ILogService, GameObject, string, IGameplayReadinessGate, IGameplayLoadingOverlayView)
Initializes the game mode service with required dependencies.
Declaration
public void InitializeService(IGameModeSettingsDefinition settings, IPauseStrategy pauseStrategy, IPlayerInputService playerInputService, IMenuService menuService, IEventDispatcherService eventDispatcher, ILogService logService, GameObject gameWrapper, string gameplaySceneName, IGameplayReadinessGate gameplayReadinessGate = null, IGameplayLoadingOverlayView loadingOverlay = 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. |
SetMode(GameMode)
Declaration
public void SetMode(GameMode mode)
Parameters
| Type | Name | Description |
|---|---|---|
| GameMode | mode |
TogglePause()
Declaration
public void TogglePause()