Unity-Technologies/UnityCsReference · error · ArgumentNullException
Scene path cannot be null or empty.
Error message
Scene path cannot be null or empty.
What it means
Thrown by LoadableSceneIdEditorUtility.CreateLoadableSceneId(string) when scenePath is null or empty. It is a defensive guard at the top of the factory that builds a LoadableSceneId handle from a scene asset path.
Source
Thrown at Editor/Mono/Loadable/LoadableSceneIdEditorUtility.cs:68
return null;
return AssetDatabase.LoadMainAssetAtGUID(guid) as SceneAsset;
}
/// <summary>
/// Create a LoadableSceneId object based on a scene's path.
/// </summary>
/// <param name="scenePath">The scene's path within the project. Must end with .unity extension.</param>
/// <returns>A LoadableSceneId handle populated to reference the provided scene.</returns>
/// <exception cref="System.ArgumentNullException">
/// Thrown if scenePath is null or empty.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown if the path doesn't end with .unity extension or if the scene asset cannot be found at the specified path.
/// </exception>
public static LoadableSceneId CreateLoadableSceneId(string scenePath)
{
if (string.IsNullOrEmpty(scenePath))
throw new ArgumentNullException(nameof(scenePath), "Scene path cannot be null or empty.");
if (!scenePath.EndsWith(".unity", StringComparison.CurrentCultureIgnoreCase))
throw new ArgumentException($"Path {scenePath} is not a scene path. Must end with .unity extension.");
var guid = new GUID(AssetDatabase.AssetPathToGUID(scenePath));
if (guid.Empty())
throw new ArgumentException($"Couldn't locate scene asset at path {scenePath}");
return CreateLoadableSceneId(guid);
}
}
}
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Validate the scene path is non-empty before calling, and skip or report the offending entry.
- Fix the source of the path (serialized reference, config, inspector field) so it is populated.
- Provide a clear error to the user identifying which scene entry is missing its path.
Example fix
// before
var id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(scenePath);
// after
if (string.IsNullOrEmpty(scenePath))
throw new InvalidOperationException("Scene reference is unassigned in build list.");
var id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(scenePath); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(scenePath)) throw new InvalidOperationException("Scene path is unassigned."); Type guard
static bool IsValidScenePath(string p) => !string.IsNullOrEmpty(p);
Try / catch
try { CreateLoadableSceneId(scenePath); }
catch (ArgumentNullException) { Debug.LogError("Scene path missing; check the source reference."); } Prevention
- Validate scene paths from config before use
- Use SceneAsset references over stored strings
- Report which entry is missing
When it happens
Trigger: Calling CreateLoadableSceneId with a null or empty string — e.g. a serialized field that was never assigned, a path read from a broken reference, or a config value left blank.
Common situations: Editor tooling or build scripts that consume a scene list from a configuration object where an entry is unset. A SceneAsset reference that resolved to a null path after the asset was moved or deleted.
Related errors
- Path {scenePath} is not a scene path. Must end with .unity e
- Preview scene could not be created
- Couldn't locate scene asset at path {scenePath}
- No material targets provided
- src
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/e174875d0b126dd0.
Report an issue: GitHub.