EllanJiang/GameFramework · error · GameFrameworkException
You must set read-write path before add load resource agent…
Error message
You must set read-write path before add load resource agent helper.
What it means
Thrown by ResourceManager.SetReadWritePath when the resource loader already has agents added (TotalAgentCount > 0). The read-write path feeds agent helpers, so changing it after agents exist would leave them with stale paths; set the path before AddLoadResourceAgentHelper is used.
Solutions
- Call SetReadWritePath before adding any resource agent helpers
- Reorder the initialization sequence: paths, mode, then agent helpers
- Restart/reinitialize the module if the path genuinely must change
Example fix
// before loader.AddLoadResourceAgentHelper(helper); resourceComponent.SetReadWritePath(path); // after resourceComponent.SetReadWritePath(path); loader.AddLoadResourceAgentHelper(helper);
Defensive patterns
Strategy: validation
Validate before calling
if (resourceComponent.ResourceLoaderTotalAgentCount == 0) resourceComponent.SetReadWritePath(path);
Try / catch
try { resourceComponent.SetReadWritePath(path); }
catch (GameFrameworkException) { Log.Error("Set read-write path before adding load resource agent helpers."); } Prevention
- Configure paths before any AddLoadResourceAgentHelper call
- Keep resource setup in one ordered function
- Do not attempt runtime path reconfiguration
When it happens
Trigger: Calling SetReadWritePath after AddLoadResourceAgentHelper or any flow that registers resource agents.
Common situations: Reordering mistakes in startup code, or attempting to change where resources are stored while the resource system is live.
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 must set read-only path before add load resource agent…
- You can not set read-write path at this time.
- 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/8b63a0a5c4703045.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:895
/// <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)
{
throw new GameFrameworkException("You can not set read-write path at this time.");
}
if (m_ResourceLoader.TotalAgentCount > 0)
{
throw new GameFrameworkException("You must set read-write path before add load resource agent helper.");
}
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)
{View on GitHub (pinned to d0c010b051)