EllanJiang/GameFramework · error · GameFrameworkException

Setting helper is invalid.

Error message

Setting helper is invalid.

What it means

SettingManager.Count reads through m_SettingHelper, the ISettingHelper injected via SetSettingHelper. If no helper was set, the property cannot delegate and throws this GameFrameworkException. Several other SettingManager members perform the same guard.

Solutions

  1. Call SetSettingHelper with a concrete ISettingHelper implementation during initialization.
  2. Ensure GameEntry/component setup order initializes the SettingComponent before any settings access.
  3. Guard settings access behind an initialized check when using SettingManager standalone.

Example fix

// before
int count = m_SettingManager.Count;
// after
m_SettingManager.SetSettingHelper(new DefaultSettingHelper());
int count = m_SettingManager.Count;
Defensive patterns

Strategy: validation

Validate before calling

if (settingHelper == null)
{
    throw new InvalidOperationException("Call SetSettingHelper before using SettingManager.");
}

Try / catch

try { int count = settingManager.Count; }
catch (GameFrameworkException ex) when (ex.Message.Contains("Setting helper"))
{ Log.Error("SettingManager not initialized."); }

Prevention

When it happens

Trigger: Accessing SettingManager.Count (or other members that touch the helper) before calling SetSettingHelper with a valid ISettingHelper instance.

Common situations: Forgetting to register a setting helper (e.g. PlayerPrefsSettingHelper) in GameEntry; using a bare SettingManager in tests; component initialization ordering where settings are read before setup completes.

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


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/1702f158a99949ab. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Setting/SettingManager.cs:37

        /// <summary>
        /// 初始化游戏配置管理器的新实例。
        /// </summary>
        public SettingManager()
        {
            m_SettingHelper = null;
        }

        /// <summary>
        /// 获取游戏配置项数量。
        /// </summary>
        public int Count
        {
            get
            {
                if (m_SettingHelper == null)
                {
                    throw new GameFrameworkException("Setting helper is invalid.");
                }

                return m_SettingHelper.Count;
            }
        }

        /// <summary>
        /// 游戏配置管理器轮询。
        /// </summary>
        /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
        /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
        internal override void Update(float elapseSeconds, float realElapseSeconds)
        {
        }

        /// <summary>
        /// 关闭并清理游戏配置管理器。
        /// </summary>

View on GitHub (pinned to d0c010b051)