EllanJiang/GameFramework · error · GameFrameworkException
Resource manager is invalid.
Error message
Resource manager is invalid.
What it means
EntityManager.SetResourceManager rejects a null IResourceManager argument. The entity system loads entity assets through the resource manager, so a null reference would make ShowEntity and related flows fail later; the framework throws immediately to fail fast at setup time.
Solutions
- Initialize the ResourceComponent (IResourceManager) before calling SetResourceManager.
- Verify the code fetching the resource manager actually returns a live instance.
- Reorder your bootstrap sequence: resource manager -> object pool manager -> entity helper -> entity manager wiring.
Example fix
// before m_EntityManager.SetResourceManager(maybeResourceManager); // may be null // after IResourceManager resourceManager = GameEntry.GetComponent<ResourceComponent>(); Debugger.Assert(resourceManager != null, "ResourceManager missing"); m_EntityManager.SetResourceManager(resourceManager);
Defensive patterns
Strategy: validation
Validate before calling
IResourceManager resourceManager = GameEntry.GetComponent<ResourceComponent>();
if (resourceManager == null) throw new InvalidOperationException("ResourceComponent must be initialized before entity manager"); Type guard
bool HasResourceManager(EntityManager em) => em != null && em.ResourceManager != null;
Try / catch
try
{
entityManager.SetResourceManager(resourceManager);
}
catch (GameFrameworkException ex)
{
Debug.LogError($"Entity init failed: {ex.Message}");
} Prevention
- Wire ResourceComponent before EntityComponent in bootstrap.
- Assert retrieved component references are non-null before injecting.
- Keep an ordered initialization checklist for framework managers.
When it happens
Trigger: Calling EntityManager.SetResourceManager(null), usually when the ResourceComponent was not created/initialized yet or the lookup that produced the reference returned null.
Common situations: Wrong initialization order in GameEntry (EntityComponent initialized before ResourceComponent), resource component retrieval by wrong type or name, or stripped-down framework builds that omit the resource module.
Related errors
- Object pool manager is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
- Entity is invalid.
- Results is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/41b87340b926f0cb.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Entity/EntityManager.cs:222
public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)
{
if (objectPoolManager == null)
{
throw new GameFrameworkException("Object pool manager is invalid.");
}
m_ObjectPoolManager = objectPoolManager;
}
/// <summary>
/// 设置资源管理器。
/// </summary>
/// <param name="resourceManager">资源管理器。</param>
public void SetResourceManager(IResourceManager resourceManager)
{
if (resourceManager == null)
{
throw new GameFrameworkException("Resource manager is invalid.");
}
m_ResourceManager = resourceManager;
}
/// <summary>
/// 设置实体辅助器。
/// </summary>
/// <param name="entityHelper">实体辅助器。</param>
public void SetEntityHelper(IEntityHelper entityHelper)
{
if (entityHelper == null)
{
throw new GameFrameworkException("Entity helper is invalid.");
}
m_EntityHelper = entityHelper;
}View on GitHub (pinned to d0c010b051)