EllanJiang/GameFramework · error · GameFrameworkException

Object pool manager is invalid.

Error message

Object pool manager is invalid.

What it means

Thrown by ResourceManager.SetObjectPoolManager when the IObjectPoolManager argument is null. The resource system requires an object pool manager to pool loaded objects; without it resource loading cannot proceed, so the library fails fast with GameFrameworkException instead of a later NullReferenceException.

Solutions

  1. Pass a valid IObjectPoolManager instance, e.g. the GameFramework component obtained via GameFrameworkEntry.GetModule<ObjectPoolManager>()
  2. Check your module initialization order so the object pool manager is created before ResourceManager.SetObjectPoolManager is called
  3. If the value can be null, guard the call with a null check and log instead of calling

Example fix

// before
resourceManager.SetObjectPoolManager(null);
// after
var objectPoolManager = GameFrameworkEntry.GetModule<ObjectPoolManager>();
if (objectPoolManager != null) resourceManager.SetObjectPoolManager(objectPoolManager);
Defensive patterns

Strategy: validation

Validate before calling

if (objectPoolManager == null) throw new InvalidOperationException("objectPoolManager must be initialized before SetObjectPoolManager");

Type guard

bool IsValid(IObjectPoolManager m) => m != null;

Try / catch

try { resourceManager.SetObjectPoolManager(poolManager); } catch (GameFrameworkException ex) { Debug.LogError($"Resource init failed: {ex.Message}"); }

Prevention

When it happens

Trigger: Calling SetObjectPoolManager(null), or passing an uninitialized/unassigned variable or a failed GetComponent<T>() result that is null.

Common situations: Unity initialization order mistakes: ResourceComponent set up before ObjectPoolComponent is registered; dependency-injection container not yet populated; renaming a field so the argument becomes null.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/61366d6856ca0c08. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:984

        public void SetCurrentVariant(string currentVariant)
        {
            if (m_RefuseSetFlag)
            {
                throw new GameFrameworkException("You can not set current variant at this time.");
            }

            m_CurrentVariant = currentVariant;
        }

        /// <summary>
        /// 设置对象池管理器。
        /// </summary>
        /// <param name="objectPoolManager">对象池管理器。</param>
        public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)
        {
            if (objectPoolManager == null)
            {
                throw new GameFrameworkException("Object pool manager is invalid.");
            }

            m_ResourceLoader.SetObjectPoolManager(objectPoolManager);
        }

        /// <summary>
        /// 设置文件系统管理器。
        /// </summary>
        /// <param name="fileSystemManager">文件系统管理器。</param>
        public void SetFileSystemManager(IFileSystemManager fileSystemManager)
        {
            if (fileSystemManager == null)
            {
                throw new GameFrameworkException("File system manager is invalid.");
            }

            m_FileSystemManager = fileSystemManager;
        }

View on GitHub (pinned to d0c010b051)