{"record":{"id":"844d46b3c62d0098","repo":"EllanJiang/GameFramework","slug":"check-resources-complete-callback-is-invalid","errorCode":null,"errorMessage":"Check resources complete callback is invalid.","messagePattern":"Check resources complete callback is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1219,"sourceCode":"            m_ResourceVerifier = new ResourceVerifier(this);\n            m_ResourceVerifier.ResourceVerifyStart += OnVerifierResourceVerifyStart;\n            m_ResourceVerifier.ResourceVerifySuccess += OnVerifierResourceVerifySuccess;\n            m_ResourceVerifier.ResourceVerifyFailure += OnVerifierResourceVerifyFailure;\n            m_ResourceVerifier.ResourceVerifyComplete += OnVerifierResourceVerifyComplete;\n            m_VerifyResourcesCompleteCallback = verifyResourcesCompleteCallback;\n            m_ResourceVerifier.VerifyResources(verifyResourceLengthPerFrame);\n        }\n\n        /// <summary>\n        /// 使用可更新模式并检查资源。\n        /// </summary>\n        /// <param name=\"ignoreOtherVariant\">是否忽略处理其它变体的资源，若不忽略，将会移除其它变体的资源。</param>\n        /// <param name=\"checkResourcesCompleteCallback\">使用可更新模式并检查资源完成时的回调函数。</param>\n        public void CheckResources(bool ignoreOtherVariant, CheckResourcesCompleteCallback checkResourcesCompleteCallback)\n        {\n            if (checkResourcesCompleteCallback == null)\n            {\n                throw new GameFrameworkException(\"Check resources complete callback is invalid.\");\n            }\n\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"You must set resource mode first.\");\n            }\n\n            if (m_ResourceMode != ResourceMode.Updatable && m_ResourceMode != ResourceMode.UpdatableWhilePlaying)\n            {\n                throw new GameFrameworkException(\"You can not use CheckResources without updatable resource mode.\");\n            }\n\n            if (m_ResourceChecker == null)\n            {\n                throw new GameFrameworkException(\"You can not use CheckResources at this time.\");\n            }\n\n            m_RefuseSetFlag = true;","sourceCodeStart":1201,"sourceCodeEnd":1237,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1201-L1237","documentation":"Thrown by ResourceManager.CheckResources when the checkResourcesCompleteCallback parameter is null. CheckResources needs the callback to deliver the result of comparing local resources against the version list, so it rejects a null delegate up front.","triggerScenarios":"Calling CheckResources(bool, CheckResourcesCompleteCallback) with null, e.g. m_ResourceManager.CheckResources(false, null) or passing a variable that was never assigned.","commonSituations":"Removing the completion handler during refactoring; forgetting to subscribe in the update flow; a null-returning factory for the handler.","solutions":["Pass a non-null CheckResourcesCompleteCallback implementation.","Verify the delegate variable is assigned before the call.","Catch GameFrameworkException to catch the bad call during development."],"exampleFix":"// before\nm_ResourceManager.CheckResources(ignoreOtherVariant, null);\n// after\nm_ResourceManager.CheckResources(ignoreOtherVariant, OnCheckResourcesComplete);\n\nprivate void OnCheckResourcesComplete(int removedCount, int updateCount, int updateLength, long updateLengthBytes) { ... }","handlingStrategy":"retry","validationCode":"// defer until the current operation completes\nif (m_UpdateOperationInProgress) {\n    m_PendingVerify = () => m_ResourceManager.VerifyResources(len, cb);\n    return;\n}\nm_ResourceManager.VerifyResources(len, cb);","typeGuard":null,"tryCatchPattern":"try { m_ResourceManager.VerifyResources(len, cb); } catch (GameFrameworkException ex) { QueueVerifyForAfterCurrentOperation(); }","preventionTips":["Serialize all resource state operations through one state machine.","Disable UI triggers while an update operation is pending.","Always drive the next step from the previous step's complete callback."],"tags":["unity","gameframework","argument-validation","callback"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}