EllanJiang/GameFramework · error · GameFrameworkException

You can not use InitResources at this time.

Error message

You can not use InitResources at this time.

What it means

Thrown by ResourceManager.InitResources when m_ResourceIniter is null. Even in Package mode, the internal ResourceIniter component must have been created/attached (via the framework component setup) before InitResources can delegate to it.

Solutions

  1. Ensure the GameFramework ResourceComponent has fully initialized (Awake created all helper components) before calling InitResources.
  2. Do not create a raw ResourceManager yourself; use the provided component lifecycle.
  3. Re-add/repair the ResourceIniter helper if it was removed or destroyed.

Example fix

// before
var rm = new ResourceManager();
rm.InitResources(OnInitResourcesComplete);
// after
// use the GameFramework ResourceComponent lifecycle
m_ResourceComponent.InitResources(OnInitResourcesComplete);
Defensive patterns

Strategy: validation

Validate before calling

if (!m_ResourceComponent.Ready) yield return new WaitUntil(() => m_ResourceComponent.Ready);
m_ResourceComponent.InitResources(OnInitResourcesComplete);

Try / catch

try { m_ResourceComponent.InitResources(cb); }
catch (GameFrameworkException e) { Log.Fatal("ResourceIniter not ready: {0}", e.Message); }

Prevention

When it happens

Trigger: Calling InitResources in Package mode before the ResourceIniter helper has been initialized, or after the ResourceManager was torn down / partially constructed outside the normal GameFramework component lifecycle.

Common situations: Manually constructing ResourceManager without the Unity ResourceComponent's Awake creating helpers, calling InitResources too early in the frame, or destroying the component then reusing it.

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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:1107

        {
            if (initResourcesCompleteCallback == null)
            {
                throw new GameFrameworkException("Init resources complete callback is invalid.");
            }

            if (m_ResourceMode == ResourceMode.Unspecified)
            {
                throw new GameFrameworkException("You must set resource mode first.");
            }

            if (m_ResourceMode != ResourceMode.Package)
            {
                throw new GameFrameworkException("You can not use InitResources without package resource mode.");
            }

            if (m_ResourceIniter == null)
            {
                throw new GameFrameworkException("You can not use InitResources at this time.");
            }

            m_RefuseSetFlag = true;
            m_InitResourcesCompleteCallback = initResourcesCompleteCallback;
            m_ResourceIniter.InitResources(m_CurrentVariant);
        }

        /// <summary>
        /// 使用可更新模式并检查版本资源列表。
        /// </summary>
        /// <param name="latestInternalResourceVersion">最新的内部资源版本号。</param>
        /// <returns>检查版本资源列表结果。</returns>
        public CheckVersionListResult CheckVersionList(int latestInternalResourceVersion)
        {
            if (m_ResourceMode == ResourceMode.Unspecified)
            {
                throw new GameFrameworkException("You must set resource mode first.");
            }

View on GitHub (pinned to d0c010b051)