EllanJiang/GameFramework · error · GameFrameworkException
Asset name is invalid.
Error message
Asset name is invalid.
What it means
HasAsset(assetName) checks whether an asset exists in the current resource system. A null or empty assetName cannot identify any asset, so ResourceManager throws this GameFrameworkException as argument validation before delegating to the resource loader.
Solutions
- Validate the asset name is non-empty before calling HasAsset.
- Fix the data source (config row, prefab reference, save data) that yields the empty name.
- Return a sensible default (HasAssetResult.NotExist or skip) when the name is empty instead of calling the API.
Example fix
// before
var result = resourceManager.HasAsset(assetName); // may be empty
// after
if (!string.IsNullOrEmpty(assetName))
{
var result = resourceManager.HasAsset(assetName);
} Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(assetName)) return HasAssetResult.NotExist;
Type guard
static bool IsValidAssetName(string n) => !string.IsNullOrEmpty(n);
Try / catch
try { var r = rm.HasAsset(name); } catch (GameFrameworkException ex) { Log.Error(ex.Message); return HasAssetResult.NotExist; } Prevention
- Validate asset names where they are constructed
- Fix empty entries in data tables/config
- Log the offending name source when empty
When it happens
Trigger: Calling HasAsset(null) or HasAsset("") — e.g. an asset name field that was never assigned, or a name stripped from a path that turned out empty.
Common situations: Building asset names dynamically from config or a clicked item whose key is missing; concatenating path segments where one is empty; deserialized data missing the asset field.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Results is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
- Owner is invalid.
- Resource manager is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/dcd50aea3993858a.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:1452
/// <summary>
/// 获取所有加载资源任务的信息。
/// </summary>
/// <param name="results">所有加载资源任务的信息。</param>
public void GetAllLoadAssetInfos(List<TaskInfo> results)
{
m_ResourceLoader.GetAllLoadAssetInfos(results);
}
/// <summary>
/// 检查资源是否存在。
/// </summary>
/// <param name="assetName">要检查资源的名称。</param>
/// <returns>检查资源是否存在的结果。</returns>
public HasAssetResult HasAsset(string assetName)
{
if (string.IsNullOrEmpty(assetName))
{
throw new GameFrameworkException("Asset name is invalid.");
}
return m_ResourceLoader.HasAsset(assetName);
}
/// <summary>
/// 异步加载资源。
/// </summary>
/// <param name="assetName">要加载资源的名称。</param>
/// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
public void LoadAsset(string assetName, LoadAssetCallbacks loadAssetCallbacks)
{
if (string.IsNullOrEmpty(assetName))
{
throw new GameFrameworkException("Asset name is invalid.");
}
if (loadAssetCallbacks == null)View on GitHub (pinned to d0c010b051)