{"record":{"id":"3a2aa84e95f18a66","repo":"EllanJiang/GameFramework","slug":"resource-helper-is-invalid-resourcemanager-resourceloader","errorCode":null,"errorMessage":"Resource helper is invalid.","messagePattern":"Resource helper is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceLoader.AssetObject.cs","lineNumber":59,"sourceCode":"                        return base.CustomCanReleaseFlag && targetReferenceCount <= 0;\n                    }\n                }\n\n                public static AssetObject Create(string name, object target, List<object> dependencyAssets, object resource, IResourceHelper resourceHelper, ResourceLoader resourceLoader)\n                {\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))","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceLoader.AssetObject.cs#L41-L77","documentation":"AssetObject.Create validates that the resourceHelper argument is non-null. The helper is needed later for releasing/unloading the asset, so an AssetObject cannot be constructed without one. Fail-fast guard inside the resource loader.","triggerScenarios":"Calling AssetObject.Create with resourceHelper == null, typically when wiring a custom resource helper or when the ResourceManager was initialized without setting m_ResourceHelper.","commonSituations":"Forgot to assign the resource helper (e.g. in ResourceComponent Start or ResourceManager initialize) before loading assets; a refactor renamed/reordered arguments so null landed in the helper slot.","solutions":["Set the resource helper before loading: m_ResourceManager.SetResourceHelper(new DefaultResourceHelper()) or via ResourceComponent's inspector.","Check argument order at the AssetObject.Create call site to ensure the helper isn't shifted/null.","Initialize ResourceManager fully (helper, paths, pools) before any asset load."],"exampleFix":"// before\nm_ResourceManager.InitResources(); // helper never set\n// after\nm_ResourceManager.SetResourceHelper(new DefaultResourceHelper());\nm_ResourceManager.InitResources();","handlingStrategy":"validation","validationCode":"if (resourceComponent.ResourceHelper == null) resourceComponent.ResourceHelper = new DefaultResourceHelper();","typeGuard":"bool HelperReady => m_ResourceManager.m_ResourceHelper != null;","tryCatchPattern":null,"preventionTips":["Assign the resource helper in Awake/inspector before any loads.","Centralize ResourceManager initialization in one method.","Check argument order when calling AssetObject.Create directly."],"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"}