EllanJiang/GameFramework · error · GameFrameworkException
Scene asset name is invalid.
Error message
Scene asset name is invalid.
What it means
ResourceManager.LoadScene(sceneAssetName, loadSceneCallbacks) throws this when sceneAssetName is null or empty. Scene names are keys used to locate and load scene assets through the resource system, so an empty name is rejected before any loading work starts.
Solutions
- Pass a valid non-empty scene asset name, e.g. 'Assets/GameMain/Scenes/Main.unity'.
- Validate with string.IsNullOrEmpty before calling LoadScene and log/skip on invalid names.
- Fix the configuration or reference that supplied the empty scene name.
Example fix
// before
m_ResourceManager.LoadScene(sceneName, new LoadSceneCallbacks(OnSceneLoadSuccess, OnSceneLoadFailure));
// after
if (string.IsNullOrEmpty(sceneName))
{
Log.Error("Scene name is empty, cannot load.");
return;
}
m_ResourceManager.LoadScene(sceneName, new LoadSceneCallbacks(OnSceneLoadSuccess, OnSceneLoadFailure)); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(sceneAssetName))
{
Log.Error("LoadScene skipped: sceneAssetName is null or empty.");
return;
} Type guard
static bool IsValidSceneName(string name) => !string.IsNullOrEmpty(name);
Try / catch
try
{
m_ResourceManager.LoadScene(sceneAssetName, callbacks);
}
catch (GameFrameworkException ex)
{
Log.Error("LoadScene failed: {0}", ex.Message);
} Prevention
- Keep scene names in a central constants/config class validated at startup.
- Check that scene renames/deletions are propagated to all call sites.
- Validate UI/config inputs that feed LoadScene.
When it happens
Trigger: Calling the two-argument LoadScene overload with a null or empty sceneAssetName, e.g. a scene name field left unset.
Common situations: Scene name read from a config/UI field that was never filled in; a rename in the project that broke a hardcoded scene string set to empty; procedural string building that produced "".
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Resource name is invalid.
- Resource extension is invalid.
- Apply resources complete callback is invalid.
- Update resources complete callback is invalid.
- Asset is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/3c9e50974132968f.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:1658
if (m_ResourceLoader == null)
{
return;
}
m_ResourceLoader.UnloadAsset(asset);
}
/// <summary>
/// 异步加载场景。
/// </summary>
/// <param name="sceneAssetName">要加载场景资源的名称。</param>
/// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
public void LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks)
{
if (string.IsNullOrEmpty(sceneAssetName))
{
throw new GameFrameworkException("Scene asset name is invalid.");
}
if (loadSceneCallbacks == null)
{
throw new GameFrameworkException("Load scene callbacks is invalid.");
}
m_ResourceLoader.LoadScene(sceneAssetName, Constant.DefaultPriority, loadSceneCallbacks, null);
}
/// <summary>
/// 异步加载场景。
/// </summary>
/// <param name="sceneAssetName">要加载场景资源的名称。</param>
/// <param name="priority">加载场景资源的优先级。</param>
/// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
public void LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks)
{View on GitHub (pinned to d0c010b051)