{"record":{"id":"b9655c383621f828","repo":"Unity-Technologies/UnityCsReference","slug":"scene-path-0-contains-invalid-directory-separa","errorCode":null,"errorMessage":"Scene path \"{0}\" contains invalid directory separators.","messagePattern":"Scene path \"(.+?)\" contains invalid directory separators\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs","lineNumber":213,"sourceCode":"        ///<example>\n        ///  <code source=\"../../../Modules/ContentBuild/Tests/local.test.build-examples/Editor/BuildPipeline/BuildPipeline_BuildPlayer.cs\"/>\n        ///</example>\n        ///<seealso cref=\"BuildPlayerWindow.DefaultBuildMethods.BuildPlayer\" />\n        public static BuildReport BuildPlayer(BuildPlayerOptions buildPlayerOptions)\n        {\n            if (isBuildingPlayer)\n                throw new InvalidOperationException(\"Cannot start a new build because there is already a build in progress.\");\n\n            if (buildPlayerOptions.targetGroup == BuildTargetGroup.Unknown)\n                buildPlayerOptions.targetGroup = GetBuildTargetGroup(buildPlayerOptions.target);\n\n            string locationPathNameError;\n            if (!ValidateLocationPathNameForBuildTarget(buildPlayerOptions.locationPathName, buildPlayerOptions.target, buildPlayerOptions.subtarget, buildPlayerOptions.options, out locationPathNameError))\n                throw new ArgumentException(locationPathNameError);\n\n            string scenesError;\n            if (!ValidateScenePaths(buildPlayerOptions.scenes, out scenesError))\n                throw new ArgumentException(scenesError);\n\n            if ((buildPlayerOptions.options & BuildOptions.AcceptExternalModificationsToPlayer) == BuildOptions.AcceptExternalModificationsToPlayer)\n            {\n                CanAppendBuild canAppend = BuildCanBeAppended(buildPlayerOptions.target, buildPlayerOptions.locationPathName);\n                if (canAppend == CanAppendBuild.Unsupported)\n                    throw new InvalidOperationException(\"The build target does not support build appending.\");\n                if (canAppend == CanAppendBuild.No)\n                    throw new InvalidOperationException(\"The build cannot be appended.\");\n            }\n\n            if (buildPlayerOptions.scenes != null)\n            {\n                for (int i = 0; i < buildPlayerOptions.scenes.Length; i++)\n                    buildPlayerOptions.scenes[i] = buildPlayerOptions.scenes[i].Replace('\\\\', '/').Replace(\"//\", \"/\");\n            }\n\n            if ((buildPlayerOptions.options & BuildOptions.Development) == 0)\n            {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs#L195-L231","documentation":"Thrown by ValidateScenePaths during BuildPlayer when a scene path contains triple forward slashes ('///') after backslash-to-forward-slash normalization. The build pipeline normalizes path separators but rejects paths that still contain '///' since they represent an ambiguous directory structure that cannot be resolved.","triggerScenarios":"Calling BuildPipeline.BuildPlayer with a BuildPlayerOptions.scenes array entry like 'Assets///Scenes/MyScene.unity', or a path where backslash normalization collapses into '///' (e.g., 'Assets\\\\//Scenes/MyScene.unity'). The validation runs on each scene string after Replace('\\\\','/') so any source path producing three consecutive slashes triggers it.","commonSituations":"Paths assembled via string concatenation with extra separators, paths sourced from external XML/JSON config files with inconsistent delimiters, cross-platform path-handling bugs where code prepends or appends '/' unconditionally, and editor scripts that build paths from user input without sanitization.","solutions":["Sanitize every scene path before passing it to BuildPlayer: path.Replace('\\\\','/'); then collapse runs of slashes with a loop or regex like Regex.Replace(path, @\"/{2,}\", \"/\").","Inspect the offending scene path printed in the error message and fix the source that generated it.","Use Unity's AssetDatabase to load scene GUIDs and resolve canonical paths instead of hand-building path strings."],"exampleFix":"// before\nvar options = new BuildPlayerOptions\n{\n    scenes = new[] { \"Assets///Scenes/Game.unity\" },\n    locationPathName = \"Build/game\",\n    target = BuildTarget.StandaloneWindows64\n};\nBuildPipeline.BuildPlayer(options);\n\n// after\nstring NormalizeScenePath(string p) =>\n    System.Text.RegularExpressions.Regex.Replace(p.Replace('\\\\', '/'), @\"/{2,}\", \"/\");\n\nvar options = new BuildPlayerOptions\n{\n    scenes = new[] { NormalizeScenePath(\"Assets///Scenes/Game.unity\") },\n    locationPathName = \"Build/game\",\n    target = BuildTarget.StandaloneWindows64\n};\nBuildPipeline.BuildPlayer(options);","handlingStrategy":"validation","validationCode":"static string NormalizeScenePath(string p)\n{\n    string normalized = p.Replace('\\\\', '/');\n    normalized = System.Text.RegularExpressions.Regex.Replace(normalized, @\"/{2,}\", \"/\");\n    if (normalized.Contains(\"///\"))\n        throw new ArgumentException($\"Scene path still invalid after normalization: {p}\");\n    return normalized;\n}\n\n// Before BuildPlayer:\noptions.scenes = options.scenes\n    .Select(NormalizeScenePath)\n    .ToArray();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always normalize scene paths with Replace('\\\\','/') and collapse repeated slashes before passing them to BuildPlayer.","Prefer loading scene paths via EditorBuildSettings.scenes or AssetDatabase to get canonical paths instead of hand-building strings.","Add a pre-build validation step in your build script that checks every scene path for '///' and fails fast with a clear message."],"tags":["unity","build-pipeline","scene-path","path-validation","buildplayer"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}