{"record":{"id":"ccc604c2cf71db9f","repo":"EllanJiang/GameFramework","slug":"scene-asset-0-is-being-loaded","errorCode":null,"errorMessage":"Scene asset '{0}' is being loaded.","messagePattern":"Scene asset '(.+?)' is being loaded\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Scene/SceneManager.cs","lineNumber":378,"sourceCode":"        {\n            if (string.IsNullOrEmpty(sceneAssetName))\n            {\n                throw new GameFrameworkException(\"Scene asset name is invalid.\");\n            }\n\n            if (m_ResourceManager == null)\n            {\n                throw new GameFrameworkException(\"You must set resource manager first.\");\n            }\n\n            if (SceneIsUnloading(sceneAssetName))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Scene asset '{0}' is being unloaded.\", sceneAssetName));\n            }\n\n            if (SceneIsLoading(sceneAssetName))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Scene asset '{0}' is being loaded.\", sceneAssetName));\n            }\n\n            if (SceneIsLoaded(sceneAssetName))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Scene asset '{0}' is already loaded.\", sceneAssetName));\n            }\n\n            m_LoadingSceneAssetNames.Add(sceneAssetName);\n            m_ResourceManager.LoadScene(sceneAssetName, priority, m_LoadSceneCallbacks, userData);\n        }\n\n        /// <summary>\n        /// 卸载场景。\n        /// </summary>\n        /// <param name=\"sceneAssetName\">场景资源名称。</param>\n        public void UnloadScene(string sceneAssetName)\n        {\n            UnloadScene(sceneAssetName, null);","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Scene/SceneManager.cs#L360-L396","documentation":"LoadScene throws this formatted error when the requested scene is already being loaded (SceneIsLoading returns true). Starting a second load for the same in-flight scene is rejected to prevent duplicate load operations.","triggerScenarios":"Calling LoadScene twice for the same sceneAssetName before the first load completes — e.g. double event dispatch, a retry loop that fires immediately, or two procedures both issuing the load.","commonSituations":"Player pressing a button twice while a scene loads, re-entrant procedure Update issuing LoadScene every frame, or event handler registered multiple times.","solutions":["Check SceneIsLoading/SceneIsLoaded before calling LoadScene and skip if already in progress","Deduplicate at the call site with a flag that clears on LoadSceneComplete","Only issue scene loads from a single owning procedure or service"],"exampleFix":"// before\nm_SceneManager.LoadScene(sceneAssetName);\n// after\nif (m_SceneManager.SceneIsLoading(sceneAssetName) || m_SceneManager.SceneIsLoaded(sceneAssetName))\n{\n    return;\n}\nm_SceneManager.LoadScene(sceneAssetName);","handlingStrategy":"validation","validationCode":"if (sceneManager.SceneIsLoading(sceneAssetName) || sceneManager.SceneIsLoaded(sceneAssetName)) return;","typeGuard":"bool IsSceneLoadable(SceneManager sm, string name) => !sm.SceneIsLoading(name) && !sm.SceneIsLoaded(name);","tryCatchPattern":"try { sceneManager.LoadScene(name); } catch (GameFrameworkException ex) when (ex.Message.Contains(\"being loaded\")) { /* already loading; ignore */ }","preventionTips":["Guard LoadScene calls with SceneIsLoading/SceneIsLoaded checks","Use a loading-in-progress flag cleared on LoadSceneComplete","Dispatch scene-load requests from a single owner to avoid duplicates"],"tags":["gameframework","scene","duplicate-operation"],"backgroundTag":"invalid-state-transition","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}