{"record":{"id":"8b7881f0ed9c4c80","repo":"Unity-Technologies/UnityCsReference","slug":"path-scenepath-is-not-a-scene-path-must-end-wit","errorCode":null,"errorMessage":"Path {scenePath} is not a scene path. Must end with .unity extension.","messagePattern":"Path (.+?) is not a scene path\\. Must end with \\.unity extension\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Loadable/LoadableSceneIdEditorUtility.cs","lineNumber":70,"sourceCode":"        }\n\n        /// <summary>\n        /// Create a LoadableSceneId object based on a scene's path.\n        /// </summary>\n        /// <param name=\"scenePath\">The scene's path within the project. Must end with .unity extension.</param>\n        /// <returns>A LoadableSceneId handle populated to reference the provided scene.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// Thrown if scenePath is null or empty.\n        /// </exception>\n        /// <exception cref=\"System.ArgumentException\">\n        /// Thrown if the path doesn't end with .unity extension or if the scene asset cannot be found at the specified path.\n        /// </exception>\n        public static LoadableSceneId CreateLoadableSceneId(string scenePath)\n        {\n            if (string.IsNullOrEmpty(scenePath))\n                throw new ArgumentNullException(nameof(scenePath), \"Scene path cannot be null or empty.\");\n            if (!scenePath.EndsWith(\".unity\", StringComparison.CurrentCultureIgnoreCase))\n                throw new ArgumentException($\"Path {scenePath} is not a scene path. Must end with .unity extension.\");\n            var guid = new GUID(AssetDatabase.AssetPathToGUID(scenePath));\n            if (guid.Empty())\n                throw new ArgumentException($\"Couldn't locate scene asset at path {scenePath}\");\n            return CreateLoadableSceneId(guid);\n        }\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":78,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Loadable/LoadableSceneIdEditorUtility.cs#L52-L78","documentation":"Thrown by CreateLoadableSceneId when scenePath is non-empty but does not end with the '.unity' extension (case-insensitive). The factory only accepts genuine scene asset paths.","triggerScenarios":"Passing a path to a non-scene asset (.prefab, .unity scene excluded on purpose, .asset), a directory path, or a path with the wrong extension. Also a typo in the extension.","commonSituations":"A UI that lets users pick any Object instead of a SceneAsset. Code that derives a scene path by string manipulation and drops or misspells the extension. Mixing prefab and scene concepts.","solutions":["Ensure the path passed is the AssetDatabase path of an actual SceneAsset.","Constrain the picker/construction to SceneAsset so the extension is always correct.","Normalize/append '.unity' only if the input is genuinely a scene path that lost its extension."],"exampleFix":"// before\nvar id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(assetPath);\n\n// after\nif (!assetPath.EndsWith(\".unity\", StringComparison.OrdinalIgnoreCase))\n    throw new ArgumentException($\"{assetPath} is not a scene.\");\nvar id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(assetPath);","handlingStrategy":"validation","validationCode":"if (!scenePath.EndsWith(\".unity\", System.StringComparison.OrdinalIgnoreCase)) throw new ArgumentException(\"Not a scene path.\");","typeGuard":"static bool IsScenePath(string p) => p != null && p.EndsWith(\".unity\", System.StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { CreateLoadableSceneId(scenePath); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\".unity\")) { Debug.LogError(ex.Message); }","preventionTips":["Constrain pickers to SceneAsset","Derive paths from SceneAsset via AssetDatabase.GetAssetPath","Normalize extensions explicitly"],"tags":["unity","editor","scene","argument-validation","file-extension"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}