EllanJiang/GameFramework · error · GameFrameworkException

Scene asset ' ' is already loaded.

Error message

Scene asset '{0}' is already loaded.

What it means

SceneManager.LoadScene throws this when the requested scene asset name is already present in the loaded-scenes set. The framework tracks scene state explicitly and refuses duplicate LoadScene calls instead of reloading or silently ignoring them, because loading an already-loaded scene would corrupt its internal bookkeeping.

Solutions

  1. Check SceneManager.SceneIsLoaded(sceneAssetName) before calling LoadScene and skip the call if true.
  2. Call UnloadScene(sceneAssetName) first if the scene genuinely needs to be reloaded.
  3. Guard with SceneManager.SceneIsLoading as well to avoid racing an in-flight load.
  4. Wrap LoadScene in try-catch on GameFrameworkException to handle duplicates gracefully.

Example fix

// before
sceneManager.LoadScene("Assets/Scenes/Main.unity");
// after
if (!sceneManager.SceneIsLoaded("Assets/Scenes/Main.unity"))
{
    sceneManager.LoadScene("Assets/Scenes/Main.unity");
}
Defensive patterns

Strategy: validation

Validate before calling

if (!sceneManager.SceneIsLoaded(sceneAssetName) && !sceneManager.SceneIsLoading(sceneAssetName))
{
    sceneManager.LoadScene(sceneAssetName, priority, userData);
}

Try / catch

try { sceneManager.LoadScene(sceneAssetName); }
catch (GameFrameworkException) { /* scene already loaded; proceed */ }

Prevention

When it happens

Trigger: Calling SceneManager.LoadScene(sceneAssetName, ...) for a scene asset that was previously loaded successfully and never unloaded, including a second call while an earlier LoadDependencyAsset-style completion is still registered.

Common situations: Re-entering a scene without calling UnloadScene first; calling LoadScene from both a menu handler and an initialization routine; duplicating a scene-load call after an async callback fires; scene state desync after an unhandled load failure.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Scene/SceneManager.cs:383

            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 already loaded.", sceneAssetName));
            }

            m_LoadingSceneAssetNames.Add(sceneAssetName);
            m_ResourceManager.LoadScene(sceneAssetName, priority, m_LoadSceneCallbacks, userData);
        }

        /// <summary>
        /// 卸载场景。
        /// </summary>
        /// <param name="sceneAssetName">场景资源名称。</param>
        public void UnloadScene(string sceneAssetName)
        {
            UnloadScene(sceneAssetName, null);
        }

        /// <summary>
        /// 卸载场景。
        /// </summary>

View on GitHub (pinned to d0c010b051)