EllanJiang/GameFramework · error · GameFrameworkException
Resource is invalid.
Error message
Resource is invalid.
What it means
AssetObject.Create requires a non-null resource; the asset object must reference the underlying resource object it was loaded from so it can be ref-counted in the resource pool. A null resource means the caller tried to register an asset with no backing resource.
Solutions
- Ensure the load pipeline resolves the Resource object and pass it to AssetObject.Create.
- Check your IResourceHelper implementation so a successful load always yields a non-null resource.
- Assert/verify the resource parameter at the call site before invoking Create.
Example fix
// before AssetObject.Create(name, target, deps, null, helper, loader); // after var resource = m_ResourcePool.Spawn(resourceName) as Resource; AssetObject.Create(name, target, deps, resource, helper, loader);
Defensive patterns
Strategy: validation
Validate before calling
if (resource == null) throw new InvalidOperationException("Resource must be resolved before AssetObject.Create."); Type guard
bool HasResource(object resource) => resource != null;
Prevention
- Resolve the Resource from the pool before creating the AssetObject.
- Make IResourceHelper implementations guarantee non-null resources on success callbacks.
- Assert non-null resource in load-success callbacks.
When it happens
Trigger: Calling AssetObject.Create (directly or via ResourceLoader paths) with resource == null, e.g. when a custom load routine passes the loaded asset as target but forgets the resource parameter.
Common situations: Custom IResourceHelper/ResourceLoader integration that returns the asset but not its resource handle; calling Create in a load-success callback where the resource lookup failed silently and null was forwarded.
Related errors
- Dependency assets is invalid.
- Resource helper is invalid.
- Resource loader is invalid.
- Resource name is invalid.
- Resource extension is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/74346566e54f5330.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.AssetObject.cs:54
{
get
{
int targetReferenceCount = 0;
m_ResourceLoader.m_AssetDependencyCount.TryGetValue(Target, out targetReferenceCount);
return base.CustomCanReleaseFlag && targetReferenceCount <= 0;
}
}
public static AssetObject Create(string name, object target, List<object> dependencyAssets, object resource, IResourceHelper resourceHelper, ResourceLoader resourceLoader)
{
if (dependencyAssets == null)
{
throw new GameFrameworkException("Dependency assets is invalid.");
}
if (resource == null)
{
throw new GameFrameworkException("Resource is invalid.");
}
if (resourceHelper == null)
{
throw new GameFrameworkException("Resource helper is invalid.");
}
if (resourceLoader == null)
{
throw new GameFrameworkException("Resource loader is invalid.");
}
AssetObject assetObject = ReferencePool.Acquire<AssetObject>();
assetObject.Initialize(name, target);
assetObject.m_DependencyAssets.AddRange(dependencyAssets);
assetObject.m_Resource = resource;
assetObject.m_ResourceHelper = resourceHelper;
assetObject.m_ResourceLoader = resourceLoader;View on GitHub (pinned to d0c010b051)