EllanJiang/GameFramework · error · GameFrameworkException
You must set localization helper first.
Error message
You must set localization helper first.
What it means
The LocalizationManager.SystemLanguage property getter requires an ILocalizationHelper to have been installed via SetLocalizationHelper. The helper is the component that actually detects the OS/device language; without it there is no way to answer the query, so the manager throws. This is an initialization-order error.
Solutions
- Ensure SetLocalizationHelper (or a LocalizationComponent in the scene) runs before any read of SystemLanguage.
- Restructure initialization so consumers query SystemLanguage in Start or later, not before localization's Awake.
- Check m_LocalizationHelper availability in your own wrapper before delegating to SystemLanguage.
Example fix
// before
void Awake() { var lang = Localization.SystemLanguage; } // helper not set yet
// after
void Start() // runs after LocalizationComponent.Awake set the helper
{
var lang = Localization.SystemLanguage;
} Defensive patterns
Strategy: validation
Validate before calling
if (LocalizationHelper == null)
Localization.SetLocalizationHelper(new DefaultLocalizationHelper());
var lang = Localization.SystemLanguage; Try / catch
try { lang = Localization.SystemLanguage; }
catch (GameFrameworkException ex) { Log.Error("Localization not initialized: " + ex.Message); lang = Language.English; } Prevention
- Keep a LocalizationComponent in the scene so the helper is set during Awake.
- Consume SystemLanguage only in Start or later, never before localization initialization.
- Centralize helper setup in one bootstrap step of the GameFramework initialization sequence.
When it happens
Trigger: Reading localization.SystemLanguage before calling SetLocalizationHelper, e.g. querying it in Awake of another component that runs before the localization component initializes its helper.
Common situations: Script execution order issues in Unity where a consumer reads SystemLanguage before LocalizationComponent's Awake ran; forgetting to add the LocalizationComponent to the scene while calling the static Localization interface; creating a raw LocalizationManager manually and skipping helper setup.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- You must set resource manager first.
- You must set entity helper first.
- You must set download manager first.
- Resource helper is invalid.
- You must set download manager first.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/9ef6c2ffbec1434c.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Localization/LocalizationManager.cs:64
if (value == Language.Unspecified)
{
throw new GameFrameworkException("Language is invalid.");
}
m_Language = value;
}
}
/// <summary>
/// 获取系统语言。
/// </summary>
public Language SystemLanguage
{
get
{
if (m_LocalizationHelper == null)
{
throw new GameFrameworkException("You must set localization helper first.");
}
return m_LocalizationHelper.SystemLanguage;
}
}
/// <summary>
/// 获取字典数量。
/// </summary>
public int DictionaryCount
{
get
{
return m_Dictionary.Count;
}
}
/// <summary>View on GitHub (pinned to d0c010b051)