Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

IStartupLocaleInitialize

interface in Unity.Localization

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Optional hook a startup selector implements to run code once after initialization completes.

Implement this interface alongside IStartupLocaleSelector when a selector needs one-time setup after the startup locale is chosen, for example subscribing to LocalizationSettings.SelectedLocaleChanged to persist later locale changes. LocalizationSettings.InitializeAsync calls IStartupLocaleInitialize.PostInitialize on each selector that implements this interface once initialization has finished. PlayerPrefLocaleSelector uses this hook to save the selected locale.

Additional resources: IStartupLocaleSelector, LocalizationSettings

<para>A selector that logs the chosen locale after startup.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class LoggingLocaleSelectorExample : IStartupLocaleSelector, IStartupLocaleInitialize { public Locale GetStartupLocale(LocalizationSettings settings) => null;

public void PostInitialize(LocalizationSettings settings) { Debug.Log($"Startup locale: {LocalizationSettings.SelectedLocale?.Code}"); } } }

Public Methods

Method Description
PostInitialize Runs one-time setup once the startup locale has been selected.