EllanJiang/GameFramework · error · GameFrameworkException

You must set resource helper first.

Error message

You must set resource helper first.

What it means

Thrown by ResourceLoader.UnloadScene when the resource helper (m_ResourceHelper) has not been assigned on the loader. Unloading scene assets requires the helper to release underlying assets; call SetResourceHelper before any UnloadScene call.

Solutions

  1. Call resourceComponent.SetResourceHelper(new DefaultResourceHelper()) (or your custom helper) during startup, before any scene unload.
  2. Reorder initialization so the resource helper is registered before UnloadScene can be called.
  3. Guard scene unload calls behind an initialization-complete flag.

Example fix

// before
resourceComponent.UnloadScene(sceneName, unloadCallbacks);
// after
resourceComponent.SetResourceHelper(new DefaultResourceHelper()); // at init time
resourceComponent.UnloadScene(sceneName, unloadCallbacks);
Defensive patterns

Strategy: validation

Validate before calling

// Verify the helper is set before unloading
if (!resourceComponent.ResourceHelperSet) // or your own init flag
    { Log.Error("Resource helper not set; aborting UnloadScene"); return; }

Prevention

When it happens

Trigger: Calling UnloadScene (or ResourceLoader.UnloadScene) when ResourceManager.m_ResourceHelper is null — i.e. SetResourceHelper was never called before unloading a scene.

Common situations: Forgetting resourceComponent.SetResourceHelper(...) during initialization, unloading scenes in a code path that runs before resource component setup, or a custom bootstrap that skips helper registration.

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/6c0ecafee0addb81. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.cs:434

                m_TaskPool.AddTask(mainTask);
                if (!resourceInfo.Ready)
                {
                    m_ResourceManager.UpdateResource(resourceInfo.ResourceName);
                }
            }

            /// <summary>
            /// 异步卸载场景。
            /// </summary>
            /// <param name="sceneAssetName">要卸载场景资源的名称。</param>
            /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param>
            /// <param name="userData">用户自定义数据。</param>
            public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
            {
                if (m_ResourceManager.m_ResourceHelper == null)
                {
                    throw new GameFrameworkException("You must set resource helper first.");
                }

                object asset = null;
                if (m_SceneToAssetMap.TryGetValue(sceneAssetName, out asset))
                {
                    m_SceneToAssetMap.Remove(sceneAssetName);
                    m_AssetPool.Unspawn(asset);
                    m_AssetPool.ReleaseObject(asset);
                }
                else
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not find asset of scene '{0}'.", sceneAssetName));
                }

                m_ResourceManager.m_ResourceHelper.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData);
            }

            /// <summary>

View on GitHub (pinned to d0c010b051)