EllanJiang/GameFramework · error · GameFrameworkException
Localization helper is invalid.
Error message
Localization helper is invalid.
What it means
SetLocalizationHelper rejects a null ILocalizationHelper. The helper is mandatory for localization to read dictionaries and detect the system language, so installing a null one would corrupt the manager's state for all later calls; the library validates the argument and throws immediately.
Solutions
- Pass a valid ILocalizationHelper instance, e.g. localization.SetLocalizationHelper(new DefaultLocalizationHelper()).
- Verify the object you pass actually implements ILocalizationHelper and is not null due to a failed load.
- Null-check or assert the helper at the call site to fail earlier with a clearer message.
Example fix
// before
m_LocalizationHelper = GetComponent<ILocalizationHelper>(); // may be null
Localization.SetLocalizationHelper(m_LocalizationHelper);
// after
var helper = (ILocalizationHelper)GetComponent<DefaultLocalizationHelper>();
if (helper != null)
{
Localization.SetLocalizationHelper(helper);
} Defensive patterns
Strategy: validation
Validate before calling
if (localizationHelper != null)
Localization.SetLocalizationHelper(localizationHelper);
else
Log.Error("Localization helper not assigned"); Type guard
static bool IsValidHelper(ILocalizationHelper h) => h != null;
Try / catch
try { Localization.SetLocalizationHelper(helper); }
catch (GameFrameworkException ex) { Log.Error("Helper is null: " + ex.Message); } Prevention
- Check inspector/asset references for the helper before calling SetLocalizationHelper.
- Fail fast in your own bootstrap if the helper could not be created.
- Prefer instantiating a concrete helper (e.g. DefaultLocalizationHelper) over GetComponent-based lookup that can return null.
When it happens
Trigger: Calling SetLocalizationHelper(null), typically because a helper field/component was never assigned or a factory call that was supposed to create the helper returned null.
Common situations: Helper instance not wired up in the Unity inspector; Resources.Load for a helper prefab/asset failed and returned null; a custom helper registered behind a conditional compile flag that is disabled.
Related errors
- Data string is invalid.
- Data bytes is invalid.
- Full path is invalid.
- Key is invalid.
- Resource manager is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/c15e90615965af05.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Localization/LocalizationManager.cs:195
/// <summary>
/// 设置本地化数据提供者辅助器。
/// </summary>
/// <param name="dataProviderHelper">本地化数据提供者辅助器。</param>
public void SetDataProviderHelper(IDataProviderHelper<ILocalizationManager> dataProviderHelper)
{
m_DataProvider.SetDataProviderHelper(dataProviderHelper);
}
/// <summary>
/// 设置本地化辅助器。
/// </summary>
/// <param name="localizationHelper">本地化辅助器。</param>
public void SetLocalizationHelper(ILocalizationHelper localizationHelper)
{
if (localizationHelper == null)
{
throw new GameFrameworkException("Localization helper is invalid.");
}
m_LocalizationHelper = localizationHelper;
}
/// <summary>
/// 确保二进制流缓存分配足够大小的内存并缓存。
/// </summary>
/// <param name="ensureSize">要确保二进制流缓存分配内存的大小。</param>
public void EnsureCachedBytesSize(int ensureSize)
{
DataProvider<ILocalizationManager>.EnsureCachedBytesSize(ensureSize);
}
/// <summary>
/// 释放缓存的二进制流。
/// </summary>
public void FreeCachedBytes()View on GitHub (pinned to d0c010b051)