{"record":{"id":"5b5b8f7ebf968d99","repo":"EllanJiang/GameFramework","slug":"resource-loader-is-invalid","errorCode":null,"errorMessage":"Resource loader is invalid.","messagePattern":"Resource loader is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceLoader.AssetObject.cs","lineNumber":64,"sourceCode":"                {\n                    if (dependencyAssets == null)\n                    {\n                        throw new GameFrameworkException(\"Dependency assets is invalid.\");\n                    }\n\n                    if (resource == null)\n                    {\n                        throw new GameFrameworkException(\"Resource is invalid.\");\n                    }\n\n                    if (resourceHelper == null)\n                    {\n                        throw new GameFrameworkException(\"Resource helper is invalid.\");\n                    }\n\n                    if (resourceLoader == null)\n                    {\n                        throw new GameFrameworkException(\"Resource loader is invalid.\");\n                    }\n\n                    AssetObject assetObject = ReferencePool.Acquire<AssetObject>();\n                    assetObject.Initialize(name, target);\n                    assetObject.m_DependencyAssets.AddRange(dependencyAssets);\n                    assetObject.m_Resource = resource;\n                    assetObject.m_ResourceHelper = resourceHelper;\n                    assetObject.m_ResourceLoader = resourceLoader;\n\n                    foreach (object dependencyAsset in dependencyAssets)\n                    {\n                        int referenceCount = 0;\n                        if (resourceLoader.m_AssetDependencyCount.TryGetValue(dependencyAsset, out referenceCount))\n                        {\n                            resourceLoader.m_AssetDependencyCount[dependencyAsset] = referenceCount + 1;\n                        }\n                        else\n                        {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceLoader.AssetObject.cs#L46-L82","documentation":"AssetObject.Create validates that the resourceLoader argument is non-null, since the created AssetObject needs the loader for reference counting and release/shutdown logic. This is the last null-argument guard before the object is acquired from the ReferencePool.","triggerScenarios":"Calling AssetObject.Create with resourceLoader == null, e.g. from custom code outside the normal ResourceLoader.LoadAsset flow, or passing an uninitialized loader field.","commonSituations":"Testing/standalone scripts constructing AssetObject directly without a loader; loader field assigned in Awake but Create called in constructor before assignment; wrong argument order in a custom overload.","solutions":["Only create AssetObjects through ResourceLoader.LoadAsset so the loader is always supplied.","If calling Create directly, pass the live ResourceLoader instance (e.g. m_ResourceManager.m_ResourceLoader).","Ensure the loader field is initialized before any load call (order Awake/Start correctly)."],"exampleFix":"// before\nAssetObject.Create(name, target, deps, resource, helper, null);\n// after\nAssetObject.Create(name, target, deps, resource, helper, m_ResourceLoader);","handlingStrategy":"validation","validationCode":"if (loader == null) throw new InvalidOperationException(\"ResourceLoader must be initialized before creating AssetObjects.\");","typeGuard":"bool LoaderReady => m_ResourceLoader != null;","tryCatchPattern":null,"preventionTips":["Create assets only through ResourceLoader.LoadAsset.","Ensure the loader field is assigned before dependent components run.","Avoid constructing AssetObject manually in tests without a loader stub."],"tags":["argument-validation","resource","gameframework"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}