EllanJiang/GameFramework · error · GameFrameworkException
You must set read-only path before add load resource agent…
Error message
You must set read-only path before add load resource agent helper.
What it means
SetReadOnlyPath throws this when the resource loader already has load resource agent helpers added (m_ResourceLoader.TotalAgentCount > 0). Paths must be configured before any agents exist because agents capture the path environment at creation time.
Solutions
- Call SetReadOnlyPath before adding any load resource agent helpers
- Reorder startup: paths first, then agent helpers
- If reconfiguration is truly needed, recreate/reinitialize the resource module
Example fix
// before loader.AddLoadResourceAgentHelper(helper); resourceComponent.SetReadOnlyPath(path); // agents exist already // after resourceComponent.SetReadOnlyPath(path); loader.AddLoadResourceAgentHelper(helper);
Defensive patterns
Strategy: validation
Validate before calling
if (resourceComponent.ResourceLoaderTotalAgentCount == 0) resourceComponent.SetReadOnlyPath(path);
Try / catch
try { resourceComponent.SetReadOnlyPath(path); }
catch (GameFrameworkException) { Log.Error("Set read-only path before adding load resource agent helpers."); } Prevention
- Establish a fixed init order: paths -> resource mode -> agent helpers
- Never interleave agent creation with path configuration
- Document the ordering contract for the resource module
When it happens
Trigger: Calling SetReadOnlyPath after AddLoadResourceAgentHelper (or equivalent agent registration) has created one or more agents.
Common situations: Calling the setter after triggering resource system startup/agent creation, or reconfiguring paths at runtime to redirect resource loading.
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
- You can not set read-only path at this time.
- You can not set read-write path at this time.
- You must set read-write path before add load resource agent…
- You can not set resource mode at this time.
- You can not set current variant at this time.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/99247e6828b17107.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:871
/// <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))
{
throw new GameFrameworkException("Read-write path is invalid.");
}
if (m_RefuseSetFlag)
{View on GitHub (pinned to d0c010b051)