logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityLocalizationService

    Unity MonoBehaviour implementation of the localization service that manages game and voice language settings.
    Integrates with Unity's Localization system to handle locale switching and responds to game settings changes through event dispatching.

    Inheritance
    object
    UnityLocalizationService
    Implements
    ILocalizationService
    IService
    IFoundationSettings
    Namespace: Serenity.Localization.Infrastructure.Services
    Assembly: Serenity.UnityLocalization.Infrastructure.dll
    Syntax
    public class UnityLocalizationService : MonoBehaviour, ILocalizationService, IService, IFoundationSettings

    Constructors

    UnityLocalizationService()

    Declaration
    public UnityLocalizationService()

    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

    Methods

    GetGameLanguage()

    Gets the currently selected game language code from Unity's localization settings.
    Returns the identifier code of the currently active locale.

    Declaration
    public string GetGameLanguage()
    Returns
    Type Description
    string

    Current game language code, or null if no locale is selected

    GetStringTableReference()

    Declaration
    public string GetStringTableReference()
    Returns
    Type Description
    string

    GetVoiceLanguage()

    Gets the currently selected voice language code.
    Returns the cached voice language value that was set through SetVoiceLanguage.

    Declaration
    public string GetVoiceLanguage()
    Returns
    Type Description
    string

    Current voice language code

    InitializeEventDispatcher(IEventDispatcherService)

    Initializes the event dispatcher service and subscribes to relevant events.
    Sets up event handling for game settings changes that affect localization.

    Declaration
    public void InitializeEventDispatcher(IEventDispatcherService eventDispatcherService)
    Parameters
    Type Name Description
    IEventDispatcherService eventDispatcherService

    Event dispatcher service for handling localization-related events

    InitializeService(ILocalizationSettings, IGameSettingsService)

    Initializes the localization service with the provided settings and dependencies.
    Sets up language keys, localization tables, and establishes default language values from game settings.

    Declaration
    public void InitializeService(ILocalizationSettings settings, IGameSettingsService gameSettingsService)
    Parameters
    Type Name Description
    ILocalizationSettings settings

    Localization settings containing language keys and tables

    IGameSettingsService gameSettingsService

    Game settings service for accessing language configuration

    Exceptions
    Type Condition
    Exception

    Thrown when configured game languages are not found in available locales

    SetEventDispatcherService(IEventDispatcherService)

    Sets the event dispatcher service reference for handling localization events.
    Stores the service instance for later use in event subscription and handling.

    Declaration
    public void SetEventDispatcherService(IEventDispatcherService eventDispatcherService)
    Parameters
    Type Name Description
    IEventDispatcherService eventDispatcherService

    Event dispatcher service to set for this localization service

    SetGameLanguage(LocalizationSetGameLanguageInput)

    Sets the game language by switching Unity's selected locale to match the specified language.
    Uses a coroutine to handle the asynchronous locale switching operation.

    Declaration
    public void SetGameLanguage(LocalizationSetGameLanguageInput input)
    Parameters
    Type Name Description
    LocalizationSetGameLanguageInput input

    DTO containing the language code to set as the new game language

    SetVoiceLanguage(LocalizationSetVoiceLanguageInput)

    Sets the voice language by storing the language code for voice asset localization.
    Currently only caches the value without additional processing.

    Declaration
    public void SetVoiceLanguage(LocalizationSetVoiceLanguageInput input)
    Parameters
    Type Name Description
    LocalizationSetVoiceLanguageInput input

    DTO containing the language code to set as the new voice language

    SubscribeToEventDispatcherEvents()

    Subscribes to event dispatcher events related to localization settings changes.
    Currently subscribes to game settings value updates to automatically sync language changes.

    Declaration
    public void SubscribeToEventDispatcherEvents()

    Implements

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