EllanJiang/GameFramework · error · GameFrameworkException
Download manager is invalid.
Error message
Download manager is invalid.
What it means
ResourceManager.SetDownloadManager throws this when the provided IDownloadManager reference is null. The updater requires a download manager to fetch remote resource updates and wires event handlers (DownloadStart/Update/Success) to it, so a null reference is rejected up front.
Solutions
- Create/add the DownloadManager component and pass the non-null instance
- Ensure initialization order: download manager exists and is initialized before SetDownloadManager
- Verify your service locator / GetComponent call actually returns an instance
Example fix
// before
resourceManager.SetDownloadManager(m_GameEntry.GetComponent<DownloadManager>()); // null if missing
// after
var dm = m_GameEntry.GetComponent<DownloadManager>();
if (dm == null) { dm = m_GameEntry.AddComponent<DownloadManager>(); }
resourceManager.SetDownloadManager(dm); Defensive patterns
Strategy: validation
Validate before calling
if (downloadManager == null) { downloadManager = AddOrGetComponent<DownloadManager>(); } Type guard
bool HasDownloadManager(IDownloadManager dm) => dm != null;
Try / catch
try { resourceManager.SetDownloadManager(dm); } catch (GameFrameworkException ex) { Log.Error("DownloadManager not initialized: " + ex.Message); } Prevention
- Initialize the DownloadManager component before the ResourceManager
- Verify framework component creation order in your game entry code
- Assert component lookups (GetComponent) return non-null during bootstrap
When it happens
Trigger: Calling SetDownloadManager before the DownloadManager component was added/initialized, passing null explicitly, or a DI/GetComponent call that returned null (e.g. missing component on the GameObject).
Common situations: Unity initialization order issues where the resource manager is set up before the download manager; forgetting to add the DownloadManager component to the game framework GameObject; typo in component lookup.
Related errors
- Resource manager is invalid.
- Data provider helper is invalid.
- Owner is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/cde1dbc35233d078.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.ResourceUpdater.cs:273
m_DownloadManager.DownloadUpdate -= OnDownloadUpdate;
m_DownloadManager.DownloadSuccess -= OnDownloadSuccess;
m_DownloadManager.DownloadFailure -= OnDownloadFailure;
}
m_UpdateWaitingInfo.Clear();
m_UpdateCandidateInfo.Clear();
m_CachedFileSystemsForGenerateReadWriteVersionList.Clear();
}
/// <summary>
/// 设置下载管理器。
/// </summary>
/// <param name="downloadManager">下载管理器。</param>
public void SetDownloadManager(IDownloadManager downloadManager)
{
if (downloadManager == null)
{
throw new GameFrameworkException("Download manager is invalid.");
}
m_DownloadManager = downloadManager;
m_DownloadManager.DownloadStart += OnDownloadStart;
m_DownloadManager.DownloadUpdate += OnDownloadUpdate;
m_DownloadManager.DownloadSuccess += OnDownloadSuccess;
m_DownloadManager.DownloadFailure += OnDownloadFailure;
}
/// <summary>
/// 增加资源更新。
/// </summary>
/// <param name="resourceName">资源名称。</param>
/// <param name="fileSystemName">资源所在的文件系统名称。</param>
/// <param name="loadType">资源加载方式。</param>
/// <param name="length">资源大小。</param>
/// <param name="hashCode">资源哈希值。</param>
/// <param name="compressedLength">压缩后大小。</param>View on GitHub (pinned to d0c010b051)