{"record":{"id":"3c9e50974132968f","repo":"EllanJiang/GameFramework","slug":"scene-asset-name-is-invalid","errorCode":null,"errorMessage":"Scene asset name is invalid.","messagePattern":"Scene asset name is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1658,"sourceCode":"\n            if (m_ResourceLoader == null)\n            {\n                return;\n            }\n\n            m_ResourceLoader.UnloadAsset(asset);\n        }\n\n        /// <summary>\n        /// 异步加载场景。\n        /// </summary>\n        /// <param name=\"sceneAssetName\">要加载场景资源的名称。</param>\n        /// <param name=\"loadSceneCallbacks\">加载场景回调函数集。</param>\n        public void LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks)\n        {\n            if (string.IsNullOrEmpty(sceneAssetName))\n            {\n                throw new GameFrameworkException(\"Scene asset name is invalid.\");\n            }\n\n            if (loadSceneCallbacks == null)\n            {\n                throw new GameFrameworkException(\"Load scene callbacks is invalid.\");\n            }\n\n            m_ResourceLoader.LoadScene(sceneAssetName, Constant.DefaultPriority, loadSceneCallbacks, null);\n        }\n\n        /// <summary>\n        /// 异步加载场景。\n        /// </summary>\n        /// <param name=\"sceneAssetName\">要加载场景资源的名称。</param>\n        /// <param name=\"priority\">加载场景资源的优先级。</param>\n        /// <param name=\"loadSceneCallbacks\">加载场景回调函数集。</param>\n        public void LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks)\n        {","sourceCodeStart":1640,"sourceCodeEnd":1676,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1640-L1676","documentation":"ResourceManager.LoadScene(sceneAssetName, loadSceneCallbacks) throws this when sceneAssetName is null or empty. Scene names are keys used to locate and load scene assets through the resource system, so an empty name is rejected before any loading work starts.","triggerScenarios":"Calling the two-argument LoadScene overload with a null or empty sceneAssetName, e.g. a scene name field left unset.","commonSituations":"Scene name read from a config/UI field that was never filled in; a rename in the project that broke a hardcoded scene string set to empty; procedural string building that produced \"\".","solutions":["Pass a valid non-empty scene asset name, e.g. 'Assets/GameMain/Scenes/Main.unity'.","Validate with string.IsNullOrEmpty before calling LoadScene and log/skip on invalid names.","Fix the configuration or reference that supplied the empty scene name."],"exampleFix":"// before\nm_ResourceManager.LoadScene(sceneName, new LoadSceneCallbacks(OnSceneLoadSuccess, OnSceneLoadFailure));\n// after\nif (string.IsNullOrEmpty(sceneName))\n{\n    Log.Error(\"Scene name is empty, cannot load.\");\n    return;\n}\nm_ResourceManager.LoadScene(sceneName, new LoadSceneCallbacks(OnSceneLoadSuccess, OnSceneLoadFailure));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(sceneAssetName))\n{\n    Log.Error(\"LoadScene skipped: sceneAssetName is null or empty.\");\n    return;\n}","typeGuard":"static bool IsValidSceneName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try\n{\n    m_ResourceManager.LoadScene(sceneAssetName, callbacks);\n}\ncatch (GameFrameworkException ex)\n{\n    Log.Error(\"LoadScene failed: {0}\", ex.Message);\n}","preventionTips":["Keep scene names in a central constants/config class validated at startup.","Check that scene renames/deletions are propagated to all call sites.","Validate UI/config inputs that feed LoadScene."],"tags":["csharp","gameframework","argument-validation","scene-loading"],"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"}