EllanJiang/GameFramework · error · GameFrameworkException
Read-only path is invalid.
Error message
Read-only path is invalid.
What it means
ResourceManager.SetReadOnlyPath throws GameFrameworkException when the readOnlyPath argument is null or an empty string. The read-only path is where built-in resources shipped with the app live; the framework refuses to configure it with an invalid value. This is a fail-fast argument validation.
Solutions
- Pass a valid non-empty absolute or relative path, e.g. Application.dataPath-based persistent or streaming path
- Check the config source that supplies the path and fix the missing/empty value
- Guard the call with string.IsNullOrEmpty before invoking SetReadOnlyPath
Example fix
// before
resourceComponent.SetReadOnlyPath(config.ReadOnlyPath); // config.ReadOnlyPath was null
// after
if (!string.IsNullOrEmpty(config.ReadOnlyPath))
{
resourceComponent.SetReadOnlyPath(config.ReadOnlyPath);
} Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(readOnlyPath)) throw new ArgumentException("readOnlyPath must be a non-empty string");
resourceComponent.SetReadOnlyPath(readOnlyPath); Type guard
bool IsValidPath(string p) => !string.IsNullOrEmpty(p);
Try / catch
try { resourceComponent.SetReadOnlyPath(path); }
catch (GameFrameworkException ex) { Log.Error("SetReadOnlyPath failed: {0}", ex.Message); } Prevention
- Validate all path config values before configuring components
- Fail fast at startup when a required path is empty
- Log the config source when a path is missing
When it happens
Trigger: Calling resourceComponent.SetReadOnlyPath(null) or resourceComponent.SetReadOnlyPath("") before any resource agents are added.
Common situations: Reading the path from a config file, PlayerPrefs, or Application.streamingAssetsPath-like source that resolves to null/empty on the target platform (e.g. a missing config key or a platform where the value is not populated).
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Read-write path is invalid.
- Resource mode is invalid.
- Offset is invalid.
- Length is invalid.
- Delta length is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/fe71987c3687d486.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:861
{
m_ResourceInfos.Clear();
m_ResourceInfos = null;
}
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>View on GitHub (pinned to d0c010b051)