Class UnityGameGraphicsService
Unity-specific implementation of game graphics service that manages quality settings, resolution, and fullscreen mode.
Namespace: Serenity.GameGraphics.Infrastructure.Services
Assembly: Serenity.UnityGameGraphics.Infrastructure.dll
Syntax
public class UnityGameGraphicsService : MonoBehaviour, IGameGraphicsService, IService, IFoundationSettings
Constructors
UnityGameGraphicsService()
Declaration
public UnityGameGraphicsService()
Fields
_eventDispatcherService
Declaration
protected IEventDispatcherService _eventDispatcherService
Field Value
| Type | Description |
|---|---|
| IEventDispatcherService |
_gameSettingsService
Declaration
protected IGameSettingsService _gameSettingsService
Field Value
| Type | Description |
|---|---|
| IGameSettingsService |
_guid
Declaration
protected string _guid
Field Value
| Type | Description |
|---|---|
| string |
_id
Declaration
protected string _id
Field Value
| Type | Description |
|---|---|
| string |
_isFullScreenKey
Declaration
protected string _isFullScreenKey
Field Value
| Type | Description |
|---|---|
| string |
_logService
Declaration
protected ILogService _logService
Field Value
| Type | Description |
|---|---|
| ILogService |
_qualityLevelKey
Declaration
protected string _qualityLevelKey
Field Value
| Type | Description |
|---|---|
| string |
_screenGateway
Declaration
protected IScreenGateway _screenGateway
Field Value
| Type | Description |
|---|---|
| IScreenGateway |
_screenResolutionKey
Declaration
protected string _screenResolutionKey
Field Value
| Type | Description |
|---|---|
| string |
Properties
Guid
Declaration
public string Guid { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Id
Declaration
public string Id { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
| Type | Description |
|---|---|
| ILogService |
ScreenGateway
The engine screen this service drives. Defaults on first use so that a subclass calling InitializeService(IGameGraphicsSettings) without going through Initialize(IGameGraphicsSettings, IEventDispatcherService, ILogService, IGameSettingsService) still works.
Declaration
protected IScreenGateway ScreenGateway { get; }
Property Value
| Type | Description |
|---|---|
| IScreenGateway |
Methods
GetCurrentQualityLevel()
Gets the name of the currently active quality level.
Declaration
public virtual string GetCurrentQualityLevel()
Returns
| Type | Description |
|---|---|
| string | The current quality level name. |
GetIsFullScreen()
Gets the current fullscreen state of the application.
Declaration
public virtual bool GetIsFullScreen()
Returns
| Type | Description |
|---|---|
| bool | True if the application is in fullscreen mode, false otherwise. |
GetQualityLevelList()
Gets the list of available quality levels from Unity's quality settings.
Declaration
public virtual string[] GetQualityLevelList()
Returns
| Type | Description |
|---|---|
| string[] | An array of quality level names. |
GetScreenResolution()
Gets the current screen resolution as a formatted string.
Declaration
public virtual string GetScreenResolution()
Returns
| Type | Description |
|---|---|
| string | The screen resolution in "WIDTHxHEIGHT" format. |
Initialize(IGameGraphicsSettings, IEventDispatcherService, ILogService, IGameSettingsService)
Declaration
public virtual void Initialize(IGameGraphicsSettings settings, IEventDispatcherService eventDispatcherService, ILogService logService, IGameSettingsService gameSettingsService)
Parameters
| Type | Name | Description |
|---|---|---|
| IGameGraphicsSettings | settings | |
| IEventDispatcherService | eventDispatcherService | |
| ILogService | logService | |
| IGameSettingsService | gameSettingsService |
Initialize(IGameGraphicsSettings, IEventDispatcherService, ILogService, IGameSettingsService, IScreenGateway)
Initializes the service against a supplied screen gateway, so the requested resolution and fullscreen state can be observed without the real display.
Declaration
public virtual void Initialize(IGameGraphicsSettings settings, IEventDispatcherService eventDispatcherService, ILogService logService, IGameSettingsService gameSettingsService, IScreenGateway screenGateway)
Parameters
| Type | Name | Description |
|---|---|---|
| IGameGraphicsSettings | settings | |
| IEventDispatcherService | eventDispatcherService | |
| ILogService | logService | |
| IGameSettingsService | gameSettingsService | |
| IScreenGateway | screenGateway | The screen to drive; null falls back to the real engine screen. |
Remarks
An overload rather than an optional parameter on the four-argument version, because that version implements Initialize(IGameGraphicsSettings, IEventDispatcherService, ILogService, IGameSettingsService): an optional parameter changes the signature, so the method would stop implementing the interface, and adding the parameter to the interface instead would break every existing implementation of it.
InitializeEventDispatcher(IEventDispatcherService)
Initializes the event dispatcher service and subscribes to relevant events.
Declaration
public void InitializeEventDispatcher(IEventDispatcherService eventDispatcherService)
Parameters
| Type | Name | Description |
|---|---|---|
| IEventDispatcherService | eventDispatcherService | The event dispatcher service to use for handling graphics events. |
InitializeService(IGameGraphicsSettings)
Initializes the graphics service with the specified settings configuration.
Declaration
public virtual void InitializeService(IGameGraphicsSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| IGameGraphicsSettings | settings | The graphics settings configuration containing key mappings and initial values. |
SetCurrentQualityLevel(SetCurrentQualityLevelInput)
Sets the current quality level to the specified level.
Declaration
public virtual void SetCurrentQualityLevel(SetCurrentQualityLevelInput input)
Parameters
| Type | Name | Description |
|---|---|---|
| SetCurrentQualityLevelInput | input | Input data containing the quality level to set. |
SetEventDispatcherService(IEventDispatcherService)
Sets the event dispatcher service for graphics event handling.
Declaration
public void SetEventDispatcherService(IEventDispatcherService eventDispatcherService)
Parameters
| Type | Name | Description |
|---|---|---|
| IEventDispatcherService | eventDispatcherService | The event dispatcher service instance. |
SetIsFullScreen(GameGraphicsSetIsFullScreenInput)
Sets the fullscreen mode state for the application.
Declaration
public virtual void SetIsFullScreen(GameGraphicsSetIsFullScreenInput input)
Parameters
| Type | Name | Description |
|---|---|---|
| GameGraphicsSetIsFullScreenInput | input | Input data containing the fullscreen state to set. |
SetScreenResolution(SetScreenResolutionInput)
Sets the screen resolution to the specified width and height.
Declaration
public virtual void SetScreenResolution(SetScreenResolutionInput input)
Parameters
| Type | Name | Description |
|---|---|---|
| SetScreenResolutionInput | input | Input data containing the width and height values to set. |
SubscribeToEventDispatcherEvents()
Subscribes to event dispatcher events related to graphics settings changes.
Declaration
public void SubscribeToEventDispatcherEvents()