EllanJiang/GameFramework · error · GameFrameworkException

You can not change resource mode at this time.

Error message

You can not change resource mode at this time.

What it means

SetResourceMode throws this when the module is already running with a different concrete resource mode (m_ResourceMode != resourceMode and m_ResourceMode != Unspecified). The resource mode is decided once during initialization and cannot be changed while resources are loaded/updated under the old mode.

Solutions

  1. Ensure SetResourceMode is called exactly once with the intended mode
  2. Unify all call sites so they agree on one mode value
  3. If a mode change is required, restart the application/module rather than mutating at runtime

Example fix

// before
if (useUpdatable) resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable);
resourceComponent.SetResourceMode(ResourceMode.Package); // second conflicting call
// after
var mode = useUpdatable ? ResourceMode.PackageAndUpdatable : ResourceMode.Package;
resourceComponent.SetResourceMode(mode); // called once
Defensive patterns

Strategy: validation

Validate before calling

var current = resourceComponent.ResourceMode;
if (current != ResourceMode.Unspecified && current != mode)
    Log.Error("Resource mode already set to {0}; refusing {1}", current, mode);
else
    resourceComponent.SetResourceMode(mode);

Try / catch

try { resourceComponent.SetResourceMode(mode); }
catch (GameFrameworkException) { Log.Error("Resource mode is locked after first initialization; use a single mode per session."); }

Prevention

When it happens

Trigger: Calling SetResourceMode a second time with a different, non-Unspecified value after the first call already took effect and the updater was initialized.

Common situations: Code paths that call SetResourceMode from two places with different values, or changing mode between editor play sessions via scripts that persist settings.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:958

                    m_ResourceChecker.ResourceNeedUpdate += OnCheckerResourceNeedUpdate;
                    m_ResourceChecker.ResourceCheckComplete += OnCheckerResourceCheckComplete;

                    m_ResourceUpdater = new ResourceUpdater(this);
                    m_ResourceUpdater.ResourceApplyStart += OnUpdaterResourceApplyStart;
                    m_ResourceUpdater.ResourceApplySuccess += OnUpdaterResourceApplySuccess;
                    m_ResourceUpdater.ResourceApplyFailure += OnUpdaterResourceApplyFailure;
                    m_ResourceUpdater.ResourceApplyComplete += OnUpdaterResourceApplyComplete;
                    m_ResourceUpdater.ResourceUpdateStart += OnUpdaterResourceUpdateStart;
                    m_ResourceUpdater.ResourceUpdateChanged += OnUpdaterResourceUpdateChanged;
                    m_ResourceUpdater.ResourceUpdateSuccess += OnUpdaterResourceUpdateSuccess;
                    m_ResourceUpdater.ResourceUpdateFailure += OnUpdaterResourceUpdateFailure;
                    m_ResourceUpdater.ResourceUpdateComplete += OnUpdaterResourceUpdateComplete;
                    m_ResourceUpdater.ResourceUpdateAllComplete += OnUpdaterResourceUpdateAllComplete;
                }
            }
            else if (m_ResourceMode != resourceMode)
            {
                throw new GameFrameworkException("You can not change resource mode at this time.");
            }
        }

        /// <summary>
        /// 设置当前变体。
        /// </summary>
        /// <param name="currentVariant">当前变体。</param>
        public void SetCurrentVariant(string currentVariant)
        {
            if (m_RefuseSetFlag)
            {
                throw new GameFrameworkException("You can not set current variant at this time.");
            }

            m_CurrentVariant = currentVariant;
        }

        /// <summary>

View on GitHub (pinned to d0c010b051)