{"record":{"id":"f6037130c321246a","repo":"EllanJiang/GameFramework","slug":"can-not-find-asset-of-scene-0","errorCode":null,"errorMessage":"Can not find asset of scene '{0}'.","messagePattern":"Can not find asset of scene '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceLoader.cs","lineNumber":446,"sourceCode":"            /// <param name=\"unloadSceneCallbacks\">卸载场景回调函数集。</param>\n            /// <param name=\"userData\">用户自定义数据。</param>\n            public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)\n            {\n                if (m_ResourceManager.m_ResourceHelper == null)\n                {\n                    throw new GameFrameworkException(\"You must set resource helper first.\");\n                }\n\n                object asset = null;\n                if (m_SceneToAssetMap.TryGetValue(sceneAssetName, out asset))\n                {\n                    m_SceneToAssetMap.Remove(sceneAssetName);\n                    m_AssetPool.Unspawn(asset);\n                    m_AssetPool.ReleaseObject(asset);\n                }\n                else\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Can not find asset of scene '{0}'.\", sceneAssetName));\n                }\n\n                m_ResourceManager.m_ResourceHelper.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData);\n            }\n\n            /// <summary>\n            /// 获取二进制资源的实际路径。\n            /// </summary>\n            /// <param name=\"binaryAssetName\">要获取实际路径的二进制资源的名称。</param>\n            /// <returns>二进制资源的实际路径。</returns>\n            /// <remarks>此方法仅适用于二进制资源存储在磁盘（而非文件系统）中的情况。若二进制资源存储在文件系统中时，返回值将始终为空。</remarks>\n            public string GetBinaryPath(string binaryAssetName)\n            {\n                ResourceInfo resourceInfo = GetResourceInfo(binaryAssetName);\n                if (resourceInfo == null)\n                {\n                    return null;\n                }","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceLoader.cs#L428-L464","documentation":"UnloadScene looks up the loaded scene's asset in m_SceneToAssetMap; if the scene asset name is not present, the scene was never loaded through this loader (or already unloaded), and the error is thrown instead of calling the helper.","triggerScenarios":"Calling UnloadScene with a scene name that was never loaded via LoadScene, that was already unloaded, or with a name that does not exactly match the loaded scene asset name.","commonSituations":"Double-unload on scene teardown, unloading a scene loaded through a different resource manager instance, name mismatch (missing 'Assets/...' prefix or wrong case), and unload racing with a failed LoadScene.","solutions":["Only call UnloadScene with the exact scene asset name previously passed to a successful LoadScene.","Track loaded scenes and skip UnloadScene for names not currently loaded.","Ensure each scene is unloaded exactly once (guard against repeated teardown calls).","Catch GameFrameworkException and log instead of crashing during shutdown sequences."],"exampleFix":"// before\nresourceComponent.UnloadScene(sceneName, callbacks); // may throw if not loaded\n// after\nif (loadedScenes.Contains(sceneName)) {\n    loadedScenes.Remove(sceneName);\n    resourceComponent.UnloadScene(sceneName, callbacks);\n}","handlingStrategy":"validation","validationCode":"// Track scenes loaded through LoadScene yourself\nif (!loadedScenes.Contains(sceneAssetName)) { Log.Warning(\"Scene not loaded: \" + sceneAssetName); return; }","typeGuard":null,"tryCatchPattern":"try { resourceComponent.UnloadScene(sceneAssetName, unloadCallbacks); }\ncatch (GameFrameworkException ex) { Log.Warning(\"UnloadScene skipped: \" + ex.Message); }","preventionTips":["Only unload scenes you successfully loaded with the exact same name","Track loaded scene names in application state","Guard teardown paths against double unload","Catch GameFrameworkException during shutdown to avoid hard crashes"],"tags":["gameframework","resource-management","scene-unloading","scene-not-found"],"backgroundTag":"resource-not-found","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"}