EllanJiang/GameFramework · error · GameFrameworkException

You can not set resource mode at this time.

Error message

You can not set resource mode at this time.

What it means

Thrown by ResourceManager.SetResourceMode when m_RefuseSetFlag is set, meaning the resource system has already initialized and locked its configuration. The resource mode (Package vs Updatable) determines the whole loading pipeline and cannot change after startup; set it before initialization.

Solutions

  1. Set the resource mode before initialization, e.g. in Awake or the inspector
  2. Remove runtime mode-switching calls after startup
  3. Rebuild the module if a mode change is genuinely required

Example fix

// before
void OnDownloadComplete() { resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable); } // refused
// after
void Awake() { resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable); }
Defensive patterns

Strategy: validation

Validate before calling

if (!resourceComponent.Initialized) resourceComponent.SetResourceMode(mode);

Try / catch

try { resourceComponent.SetResourceMode(mode); }
catch (GameFrameworkException) { Log.Error("Resource mode must be set before initialization completes."); }

Prevention

When it happens

Trigger: Calling SetResourceMode after ResourceManager initialization completes and locks the setters.

Common situations: Switching resource mode at runtime to toggle between packaged and updatable resources, or late configuration from an async load callback.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:914

            }

            m_ReadWritePath = readWritePath;
        }

        /// <summary>
        /// 设置资源模式。
        /// </summary>
        /// <param name="resourceMode">资源模式。</param>
        public void SetResourceMode(ResourceMode resourceMode)
        {
            if (resourceMode == ResourceMode.Unspecified)
            {
                throw new GameFrameworkException("Resource mode is invalid.");
            }

            if (m_RefuseSetFlag)
            {
                throw new GameFrameworkException("You can not set resource mode at this time.");
            }

            if (m_ResourceMode == ResourceMode.Unspecified)
            {
                m_ResourceMode = resourceMode;

                if (m_ResourceMode == ResourceMode.Package)
                {
                    m_PackageVersionListSerializer = new PackageVersionListSerializer();

                    m_ResourceIniter = new ResourceIniter(this);
                    m_ResourceIniter.ResourceInitComplete += OnIniterResourceInitComplete;
                }
                else if (m_ResourceMode == ResourceMode.Updatable || m_ResourceMode == ResourceMode.UpdatableWhilePlaying)
                {
                    m_UpdatableVersionListSerializer = new UpdatableVersionListSerializer();
                    m_ReadOnlyVersionListSerializer = new ReadOnlyVersionListSerializer();
                    m_ReadWriteVersionListSerializer = new ReadWriteVersionListSerializer();

View on GitHub (pinned to d0c010b051)