EllanJiang/GameFramework · error · GameFrameworkException
You can not use InitResources without package resource mode.
Error message
You can not use InitResources without package resource mode.
What it means
Thrown by ResourceManager.InitResources when the resource mode is set but is not ResourceMode.Package. InitResources is the Package-mode initialization path; Updatable/UpdatableWhilePlaying modes use the version-list flow (CheckVersionList/UpdateVersionList) instead.
Solutions
- If using updatable resources, remove InitResources and call CheckVersionList + UpdateVersionList + UpdateResources instead.
- If you really want Package mode, call SetResourceMode(ResourceMode.Package) before InitResources.
- Audit the bootstrap procedure so the mode and the init API pair correctly.
Example fix
// before resourceComponent.SetResourceMode(ResourceMode.UpdatableWhilePlaying); resourceComponent.InitResources(OnInitResourcesComplete); // after resourceComponent.SetResourceMode(ResourceMode.UpdatableWhilePlaying); resourceComponent.CheckVersionList(latestInternalResourceVersion);
Defensive patterns
Strategy: validation
Validate before calling
if (m_ResourceComponent.ResourceMode != ResourceMode.Package)
throw new InvalidOperationException("InitResources requires Package mode");
m_ResourceComponent.InitResources(OnInitResourcesComplete); Try / catch
try { m_ResourceComponent.InitResources(cb); }
catch (GameFrameworkException e) { Log.Fatal("InitResources called in non-Package mode: {0}", e.Message); } Prevention
- Pair each mode with its correct init API: Package->InitResources, Updatable->CheckVersionList/UpdateVersionList.
- Gate hot-update code with a mode check.
- Avoid copying bootstrap code between Package and Updatable projects.
When it happens
Trigger: Calling InitResources while m_ResourceMode is ResourceMode.Updatable or ResourceMode.UpdatableWhilePlaying.
Common situations: A project switched to hot-update (updatable) resource mode but kept the Package-style InitResources bootstrap call, often after a resource pipeline migration or copying sample code between projects.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- You can not use CheckVersionList without updatable resource…
- You can not use UpdateVersionList without updatable…
- You must set resource mode first.
- You can not use InitResources at this time.
- You can not use CheckVersionList at this time.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/c020b93e0bcfb4b2.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:1102
/// <summary>
/// 使用单机模式并初始化资源。
/// </summary>
/// <param name="initResourcesCompleteCallback">使用单机模式并初始化资源完成时的回调函数。</param>
public void InitResources(InitResourcesCompleteCallback initResourcesCompleteCallback)
{
if (initResourcesCompleteCallback == null)
{
throw new GameFrameworkException("Init resources complete callback is invalid.");
}
if (m_ResourceMode == ResourceMode.Unspecified)
{
throw new GameFrameworkException("You must set resource mode first.");
}
if (m_ResourceMode != ResourceMode.Package)
{
throw new GameFrameworkException("You can not use InitResources without package resource mode.");
}
if (m_ResourceIniter == null)
{
throw new GameFrameworkException("You can not use InitResources at this time.");
}
m_RefuseSetFlag = true;
m_InitResourcesCompleteCallback = initResourcesCompleteCallback;
m_ResourceIniter.InitResources(m_CurrentVariant);
}
/// <summary>
/// 使用可更新模式并检查版本资源列表。
/// </summary>
/// <param name="latestInternalResourceVersion">最新的内部资源版本号。</param>
/// <returns>检查版本资源列表结果。</returns>
public CheckVersionListResult CheckVersionList(int latestInternalResourceVersion)View on GitHub (pinned to d0c010b051)