EllanJiang/GameFramework · error · GameFrameworkException

Scene asset ' ' is not loaded yet.

Error message

Scene asset '{0}' is not loaded yet.

What it means

UnloadScene verifies the scene is actually in the loaded-scenes set before unloading. If the scene asset name is not currently loaded, the framework throws this GameFrameworkException because there is nothing to unload.

Solutions

  1. Check SceneManager.SceneIsLoaded(sceneAssetName) before calling UnloadScene and skip if false.
  2. Verify the asset name exactly matches the one used in the successful LoadScene call.
  3. Track your own loaded/unloaded state or subscribe to UnloadSceneSuccess before issuing another unload.
  4. If the scene needs replacing, confirm the prior load succeeded via LoadSceneSuccess before unloading anything.

Example fix

// before
m_SceneManager.UnloadScene(sceneName);
// after
if (m_SceneManager.SceneIsLoaded(sceneName))
{
    m_SceneManager.UnloadScene(sceneName);
}
Defensive patterns

Strategy: validation

Validate before calling

if (sceneManager.SceneIsLoaded(sceneAssetName))
{
    sceneManager.UnloadScene(sceneAssetName);
}

Try / catch

try { sceneManager.UnloadScene(sceneAssetName); }
catch (GameFrameworkException) { /* scene not loaded; nothing to do */ }

Prevention

When it happens

Trigger: Calling UnloadScene for a scene that was never loaded, was already unloaded, or whose load failed; using a scene asset name that does not exactly match the string passed to LoadScene.

Common situations: Unloading a scene that failed to load; double-unloading after an earlier success; typos or path casing/format differences between the loaded name and the unload name; unload firing after scene reset logic already cleared scenes.

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


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/7d617034da98ec37. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Scene/SceneManager.cs:428

            if (m_ResourceManager == null)
            {
                throw new GameFrameworkException("You must set resource manager first.");
            }

            if (SceneIsUnloading(sceneAssetName))
            {
                throw new GameFrameworkException(Utility.Text.Format("Scene asset '{0}' is being unloaded.", sceneAssetName));
            }

            if (SceneIsLoading(sceneAssetName))
            {
                throw new GameFrameworkException(Utility.Text.Format("Scene asset '{0}' is being loaded.", sceneAssetName));
            }

            if (!SceneIsLoaded(sceneAssetName))
            {
                throw new GameFrameworkException(Utility.Text.Format("Scene asset '{0}' is not loaded yet.", sceneAssetName));
            }

            m_UnloadingSceneAssetNames.Add(sceneAssetName);
            m_ResourceManager.UnloadScene(sceneAssetName, m_UnloadSceneCallbacks, userData);
        }

        private void LoadSceneSuccessCallback(string sceneAssetName, float duration, object userData)
        {
            m_LoadingSceneAssetNames.Remove(sceneAssetName);
            m_LoadedSceneAssetNames.Add(sceneAssetName);
            if (m_LoadSceneSuccessEventHandler != null)
            {
                LoadSceneSuccessEventArgs loadSceneSuccessEventArgs = LoadSceneSuccessEventArgs.Create(sceneAssetName, duration, userData);
                m_LoadSceneSuccessEventHandler(this, loadSceneSuccessEventArgs);
                ReferencePool.Release(loadSceneSuccessEventArgs);
            }
        }

View on GitHub (pinned to d0c010b051)