{"record":{"id":"8a61374bda3b4c83","repo":"EllanJiang/GameFramework","slug":"scene-asset-name-is-invalid-scenemanager","errorCode":null,"errorMessage":"Scene asset name is invalid.","messagePattern":"Scene asset name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Scene/SceneManager.cs","lineNumber":206,"sourceCode":"        {\n            if (resourceManager == null)\n            {\n                throw new GameFrameworkException(\"Resource manager is invalid.\");\n            }\n\n            m_ResourceManager = resourceManager;\n        }\n\n        /// <summary>\n        /// 获取场景是否已加载。\n        /// </summary>\n        /// <param name=\"sceneAssetName\">场景资源名称。</param>\n        /// <returns>场景是否已加载。</returns>\n        public bool SceneIsLoaded(string sceneAssetName)\n        {\n            if (string.IsNullOrEmpty(sceneAssetName))\n            {\n                throw new GameFrameworkException(\"Scene asset name is invalid.\");\n            }\n\n            return m_LoadedSceneAssetNames.Contains(sceneAssetName);\n        }\n\n        /// <summary>\n        /// 获取已加载场景的资源名称。\n        /// </summary>\n        /// <returns>已加载场景的资源名称。</returns>\n        public string[] GetLoadedSceneAssetNames()\n        {\n            return m_LoadedSceneAssetNames.ToArray();\n        }\n\n        /// <summary>\n        /// 获取已加载场景的资源名称。\n        /// </summary>\n        /// <param name=\"results\">已加载场景的资源名称。</param>","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Scene/SceneManager.cs#L188-L224","documentation":"SceneManager.SceneIsLoaded throws GameFrameworkException when the sceneAssetName argument is null or empty. The library treats a missing scene asset name as a programmer error rather than returning false, so the call fails fast at the boundary. A valid non-empty asset name (e.g. 'Assets/Scenes/Main.unity') is required for the membership check against loaded scenes.","triggerScenarios":"Calling SceneIsLoaded(null) or SceneIsLoaded(\"\") directly, or indirectly via LoadScene/UnloadScene paths that forward an unvalidated sceneAssetName into this check.","commonSituations":"Reading the scene name from a config/inspector field left blank, constructing asset names with string concatenation that yields an empty string, or passing a variable that was never initialized before checking scene state.","solutions":["Ensure sceneAssetName is a non-null, non-empty string before calling SceneIsLoaded","Fix the source of the empty value (blank config field, failed lookup, uninitialized variable)","Use the null/empty guard pattern before any SceneManager scene query"],"exampleFix":"// before\nbool loaded = sceneManager.SceneIsLoaded(sceneName);\n// after\nif (!string.IsNullOrEmpty(sceneName))\n{\n    bool loaded = sceneManager.SceneIsLoaded(sceneName);\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(sceneAssetName)) throw new ArgumentException(\"sceneAssetName is required\", nameof(sceneAssetName));","typeGuard":"bool IsValidSceneName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { ok = sceneManager.SceneIsLoaded(name); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Centralize scene-name validation in one helper","Never pass raw config/UI strings into SceneManager without a check"],"tags":["gameframework","scene","argument-validation"],"backgroundTag":"empty-required-field","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}