{"record":{"id":"61366d6856ca0c08","repo":"EllanJiang/GameFramework","slug":"object-pool-manager-is-invalid-resourcemanager","errorCode":null,"errorMessage":"Object pool manager is invalid.","messagePattern":"Object pool manager is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":984,"sourceCode":"        public void SetCurrentVariant(string currentVariant)\n        {\n            if (m_RefuseSetFlag)\n            {\n                throw new GameFrameworkException(\"You can not set current variant at this time.\");\n            }\n\n            m_CurrentVariant = currentVariant;\n        }\n\n        /// <summary>\n        /// 设置对象池管理器。\n        /// </summary>\n        /// <param name=\"objectPoolManager\">对象池管理器。</param>\n        public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)\n        {\n            if (objectPoolManager == null)\n            {\n                throw new GameFrameworkException(\"Object pool manager is invalid.\");\n            }\n\n            m_ResourceLoader.SetObjectPoolManager(objectPoolManager);\n        }\n\n        /// <summary>\n        /// 设置文件系统管理器。\n        /// </summary>\n        /// <param name=\"fileSystemManager\">文件系统管理器。</param>\n        public void SetFileSystemManager(IFileSystemManager fileSystemManager)\n        {\n            if (fileSystemManager == null)\n            {\n                throw new GameFrameworkException(\"File system manager is invalid.\");\n            }\n\n            m_FileSystemManager = fileSystemManager;\n        }","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L966-L1002","documentation":"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.","triggerScenarios":"Calling SetObjectPoolManager(null), or passing an uninitialized/unassigned variable or a failed GetComponent<T>() result that is null.","commonSituations":"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.","solutions":["Pass a valid IObjectPoolManager instance, e.g. the GameFramework component obtained via GameFrameworkEntry.GetModule<ObjectPoolManager>()","Check your module initialization order so the object pool manager is created before ResourceManager.SetObjectPoolManager is called","If the value can be null, guard the call with a null check and log instead of calling"],"exampleFix":"// before\nresourceManager.SetObjectPoolManager(null);\n// after\nvar objectPoolManager = GameFrameworkEntry.GetModule<ObjectPoolManager>();\nif (objectPoolManager != null) resourceManager.SetObjectPoolManager(objectPoolManager);","handlingStrategy":"validation","validationCode":"if (objectPoolManager == null) throw new InvalidOperationException(\"objectPoolManager must be initialized before SetObjectPoolManager\");","typeGuard":"bool IsValid(IObjectPoolManager m) => m != null;","tryCatchPattern":"try { resourceManager.SetObjectPoolManager(poolManager); } catch (GameFrameworkException ex) { Debug.LogError($\"Resource init failed: {ex.Message}\"); }","preventionTips":["Obtain the pool manager from GameFrameworkEntry before resource setup","Initialize modules in a fixed order (pool -> file system -> download -> resource)","Null-check module lookups immediately after GetModule"],"tags":["null-argument","resource","gameframework","initialization"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}