EllanJiang/GameFramework · error · GameFrameworkException

You can not set read-only path at this time.

Error message

You can not set read-only path at this time.

What it means

SetReadOnlyPath throws this when m_RefuseSetFlag is true, meaning the ResourceManager has already finished initialization (Initialize/Preshutdown sequence) and configuration is locked. Path setters are only allowed during setup.

Solutions

  1. Move SetReadOnlyPath earlier in startup, before ResourceManager initialization runs
  2. Remove duplicate/late SetReadOnlyPath calls once the flag is set
  3. Set the path in the Unity inspector (ResourceComponent.ReadOnlyPath) or via GameEntry before init

Example fix

// before
async void Start() { await LoadConfig(); resourceComponent.SetReadOnlyPath(cfg.Path); } // too late
// after
void Awake() { resourceComponent.SetReadOnlyPath(knownPath); } // before initialization
Defensive patterns

Strategy: validation

Validate before calling

if (!resourceComponent.Initialized) resourceComponent.SetReadOnlyPath(path); else Log.Warning("Too late to set read-only path");

Try / catch

try { resourceComponent.SetReadOnlyPath(path); }
catch (GameFrameworkException) { Log.Error("Read-only path must be set before resource initialization completes."); }

Prevention

When it happens

Trigger: Calling SetReadOnlyPath after initialization completes and m_RefuseSetFlag has been set by the framework's initialization flow.

Common situations: Deferred or late configuration (e.g. setting the path from an async callback after GameEntry initialized components), or calling SetReadOnlyPath again after resource system startup.

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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:866

            m_ReadOnlyFileSystems.Clear();
            m_ReadWriteFileSystems.Clear();
            m_ResourceGroups.Clear();
        }

        /// <summary>
        /// 设置资源只读区路径。
        /// </summary>
        /// <param name="readOnlyPath">资源只读区路径。</param>
        public void SetReadOnlyPath(string readOnlyPath)
        {
            if (string.IsNullOrEmpty(readOnlyPath))
            {
                throw new GameFrameworkException("Read-only path is invalid.");
            }

            if (m_RefuseSetFlag)
            {
                throw new GameFrameworkException("You can not set read-only path at this time.");
            }

            if (m_ResourceLoader.TotalAgentCount > 0)
            {
                throw new GameFrameworkException("You must set read-only path before add load resource agent helper.");
            }

            m_ReadOnlyPath = readOnlyPath;
        }

        /// <summary>
        /// 设置资源读写区路径。
        /// </summary>
        /// <param name="readWritePath">资源读写区路径。</param>
        public void SetReadWritePath(string readWritePath)
        {
            if (string.IsNullOrEmpty(readWritePath))
            {

View on GitHub (pinned to d0c010b051)