EllanJiang/GameFramework · error · GameFrameworkException
Can not load asset ' '.
Error message
Can not load asset '{0}'. What it means
LoadAsset could not resolve or load the requested asset and no failure callback was supplied, so the error message is thrown instead. It fires when the asset is missing from asset info, not ready, or the resource it maps to failed checks.
Solutions
- Verify the asset name/path matches the built asset list (check package catalog).
- Pass LoadAssetCallbacks with a failure callback so errors are reported instead of thrown.
- Ensure resource initialization (InitResources/UpdateResources or applicable resource mode) completed before loading.
- Check ResourceComponent mode (package vs updatable) matches your deployment.
Example fix
// before
var obj = resourceComponent.LoadAsset(assetName, typeof(GameObject));
// after
resourceComponent.LoadAsset(assetName, typeof(GameObject),
new LoadAssetCallbacks(
onSuccess, onFailure: (name, status, msg, ud) => Log.Warning($"Load failed {name}: {status} {msg}"))); Defensive patterns
Strategy: try-catch
Validate before calling
// Check asset presence via the framework's HasAsset/asset info API before loading
bool exists = resourceComponent.HasAsset(assetName);
if (!exists) { Log.Warning("Asset not in catalog: " + assetName); return; } Try / catch
try { resourceComponent.LoadAsset(assetName, typeof(GameObject), new LoadAssetCallbacks(onSuccess,
(n, s, m, u) => Log.Error($"Load failed: {n} [{s}] {m}"))); }
catch (GameFrameworkException ex) { Log.Error("LoadAsset threw: " + ex.Message); } Prevention
- Always pass LoadAssetCallbacks with a failure callback
- Validate asset names against the build catalog
- Finish resource init/update before loading
When it happens
Trigger: Calling LoadAsset with an asset name that has no entry in the asset info table, whose resource is not ready, or — as shown — when resourceInfo indicates failure and LoadAssetFailureCallback is null, so the formatted error ('Can not load asset ...') is thrown directly.
Common situations: Typo'd asset name, asset not included in the built resource packages, loading before resource tables are initialized/updated, or forgetting to pass LoadAssetCallbacks.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Can not load asset ' ' which is a binary asset.
- Can not load dependency asset
- Can not find asset of scene
- Can not load dependency asset
- Can not load scene ' '.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/3b765ab2f0a3d2e7.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.cs:319
/// <param name="assetName">要加载资源的名称。</param>
/// <param name="assetType">要加载资源的类型。</param>
/// <param name="priority">加载资源的优先级。</param>
/// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
/// <param name="userData">用户自定义数据。</param>
public void LoadAsset(string assetName, Type assetType, int priority, LoadAssetCallbacks loadAssetCallbacks, object userData)
{
ResourceInfo resourceInfo = null;
string[] dependencyAssetNames = null;
if (!CheckAsset(assetName, out resourceInfo, out dependencyAssetNames))
{
string errorMessage = Utility.Text.Format("Can not load asset '{0}'.", assetName);
if (loadAssetCallbacks.LoadAssetFailureCallback != null)
{
loadAssetCallbacks.LoadAssetFailureCallback(assetName, resourceInfo != null && !resourceInfo.Ready ? LoadResourceStatus.NotReady : LoadResourceStatus.NotExist, errorMessage, userData);
return;
}
throw new GameFrameworkException(errorMessage);
}
if (resourceInfo.IsLoadFromBinary)
{
string errorMessage = Utility.Text.Format("Can not load asset '{0}' which is a binary asset.", assetName);
if (loadAssetCallbacks.LoadAssetFailureCallback != null)
{
loadAssetCallbacks.LoadAssetFailureCallback(assetName, LoadResourceStatus.TypeError, errorMessage, userData);
return;
}
throw new GameFrameworkException(errorMessage);
}
LoadAssetTask mainTask = LoadAssetTask.Create(assetName, assetType, priority, resourceInfo, dependencyAssetNames, loadAssetCallbacks, userData);
foreach (string dependencyAssetName in dependencyAssetNames)
{
if (!LoadDependencyAsset(dependencyAssetName, priority, mainTask, userData))View on GitHub (pinned to d0c010b051)