EllanJiang/GameFramework · error · GameFrameworkException
Init resources complete callback is invalid.
Error message
Init resources complete callback is invalid.
What it means
Thrown by ResourceManager.InitResources when the initResourcesCompleteCallback argument is null. The library requires a callback to deliver the initialization result (success or failure) and refuses to start single-player-mode resource initialization without one.
Solutions
- Pass a non-null InitResourcesCompleteCallback lambda or method group, e.g. (success) => { ... }
- If the callback comes from a field/event, ensure it is assigned before calling InitResources
- Wrap initialization in a check that logs and aborts when the callback is missing
Example fix
// before
resourceManager.InitResources(null);
// after
resourceManager.InitResources(success =>
{
Debug.Log($"Init resources {(success ? "succeeded" : "failed")}");
}); Defensive patterns
Strategy: validation
Validate before calling
if (initCallback == null) throw new InvalidOperationException("initResourcesCompleteCallback must not be null"); Type guard
bool HasCallback(InitResourcesCompleteCallback cb) => cb != null;
Try / catch
try { resourceManager.InitResources(cb); } catch (GameFrameworkException ex) { Debug.LogError($"InitResources failed: {ex.Message}"); } Prevention
- Always pass an inline lambda or verified method group to InitResources
- Avoid nullable delegate fields for callbacks
- Handle both success and failure inside the callback
When it happens
Trigger: Calling InitResources(null), or passing a method reference that resolves to null (e.g. an unassigned delegate field).
Common situations: Assigning the callback through a serialized UnityEvent or field that was never wired; refactoring removed the handler but not the call.
Related errors
- Decrypt resource callback is invalid.
- Download manager is invalid.
- File system manager is invalid.
- Object pool manager is invalid.
- Release object filter callback is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/341267c54254df9d.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:1092
}
if (string.IsNullOrEmpty(m_ReadWritePath))
{
throw new GameFrameworkException("Read-write path is invalid.");
}
m_ResourceLoader.AddLoadResourceAgentHelper(loadResourceAgentHelper, m_ResourceHelper, m_ReadOnlyPath, m_ReadWritePath, m_DecryptResourceCallback);
}
/// <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;View on GitHub (pinned to d0c010b051)