EllanJiang/GameFramework · critical · GameFrameworkException
You must set resource manager first.
Error message
You must set resource manager first.
What it means
EntityManager.ShowEntity throws "You must set resource manager first." when the internal m_ResourceManager is null. The ResourceManager must be injected via SetResourceManager before any entity can be shown, since ShowEntity needs it to load the entity asset. This is an initialization-order error, not a bad argument.
Solutions
- Call entityManager.SetResourceManager(resourceManager) during framework startup, before any ShowEntity call.
- In Unity GameFramework, ensure the ResourceComponent exists in the scene and initializes before EntityComponent shows entities (defer ShowEntity to a Start/after-init callback).
- Check your GameEntry.Procedure initialization flow: resource manager must be set in the InitResources/procedure chain before entity show procedures run.
Example fix
// before entityManager.ShowEntity(entityId, assetName, groupName); // throws if not initialized // after entityManager.SetResourceManager(resourceManager); entityManager.SetEntityHelper(entityHelper); entityManager.ShowEntity(entityId, assetName, groupName);
Defensive patterns
Strategy: try-catch
Validate before calling
if (entityManager == null || !entityManager.IsAvailable) // check framework init state
return; // or defer the ShowEntity call until initialization completes Type guard
bool CanShowEntities(EntityManager em) => em != null; // plus verify SetResourceManager was called in your bootstrap
Try / catch
try { entityManager.ShowEntity(entityId, assetName, groupName); }
catch (GameFrameworkException ex) when (ex.Message.Contains("set resource manager first"))
{
// queue or defer the request until framework init finishes
} Prevention
- Always call SetResourceManager during framework startup before any gameplay code runs.
- In Unity, ensure ResourceComponent initializes before procedures that show entities.
- Gate entity show calls behind a 'framework ready' flag set after initialization.
When it happens
Trigger: Calling ShowEntity (directly or via the Unity EntityComponent) before SetResourceManager was called — e.g. showing an entity in Awake before framework initialization completes, or forgetting to add the resource component that wires it up.
Common situations: GameEntry/EF-initialization ordering mistakes in Unity where EntityComponent's Awake runs before ResourceComponent sets the manager; custom bootstrap code that skips SetResourceManager.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- You must set entity helper first.
- You must set object pool manager first.
- You must set download manager first.
- Resource helper is invalid.
- You must set download manager first.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/77699bda5cf795fb.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Entity/EntityManager.cs:612
/// <param name="userData">用户自定义数据。</param>
public void ShowEntity(int entityId, string entityAssetName, string entityGroupName, object userData)
{
ShowEntity(entityId, entityAssetName, entityGroupName, Constant.DefaultPriority, userData);
}
/// <summary>
/// 显示实体。
/// </summary>
/// <param name="entityId">实体编号。</param>
/// <param name="entityAssetName">实体资源名称。</param>
/// <param name="entityGroupName">实体组名称。</param>
/// <param name="priority">加载实体资源的优先级。</param>
/// <param name="userData">用户自定义数据。</param>
public void ShowEntity(int entityId, string entityAssetName, string entityGroupName, int priority, object userData)
{
if (m_ResourceManager == null)
{
throw new GameFrameworkException("You must set resource manager first.");
}
if (m_EntityHelper == null)
{
throw new GameFrameworkException("You must set entity helper first.");
}
if (string.IsNullOrEmpty(entityAssetName))
{
throw new GameFrameworkException("Entity asset name is invalid.");
}
if (string.IsNullOrEmpty(entityGroupName))
{
throw new GameFrameworkException("Entity group name is invalid.");
}
if (HasEntity(entityId))View on GitHub (pinned to d0c010b051)