Unity-Technologies/UnityCsReference · error · ArgumentNullException
path
Error message
path
What it means
The single-path overload of AssetDatabase.MakeEditable delegates to the array overload via MakeEditable(new[] {path}). It throws ArgumentNullException when path is null, because the null guard runs before the array wrapping and before any version-control checkout logic. MakeEditable marks an asset as editable (checks it out) in the active version-control provider.
Source
Thrown at Editor/Mono/AssetDatabase/AssetDatabase.cs:136
if (assetOrMetaFilePaths == null)
throw new ArgumentNullException(nameof(assetOrMetaFilePaths));
if (outNotEditablePaths == null)
throw new ArgumentNullException(nameof(outNotEditablePaths));
UnityEngine.Profiling.Profiler.BeginSample("AssetDatabase.IsOpenForEdit");
AssetModificationProcessorInternal.IsOpenForEdit(assetOrMetaFilePaths, outNotEditablePaths, statusQueryOptions);
UnityEngine.Profiling.Profiler.EndSample();
}
[RequiredByNativeCode]
private static bool Internal_MakeEditable(string path)
{
return MakeEditable(path);
}
public static bool MakeEditable(string path)
{
if (path == null)
throw new ArgumentNullException(nameof(path));
return MakeEditable(new[] {path});
}
[RequiredByNativeCode]
private static bool Internal_MakeEditable2(string[] paths, string prompt = null, List<string> outNotEditablePaths = null)
{
return MakeEditable(paths, prompt, outNotEditablePaths);
}
public static bool MakeEditable(string[] paths, string prompt = null, List<string> outNotEditablePaths = null)
{
if (paths == null)
throw new ArgumentNullException(nameof(paths));
UnityEngine.Profiling.Profiler.BeginSample("AssetDatabase.MakeEditable");
ChangeSet changeSet = null;
var result = Provider.HandlePreCheckoutCallback(ref paths, ref changeSet);
if (result && !AssetModificationProcessorInternal.MakeEditable(paths, prompt, outNotEditablePaths))
result = false;View on GitHub (pinned to 225b0fbdb5)
Solutions
- Guard the path: if (!string.IsNullOrEmpty(path)) AssetDatabase.MakeEditable(path).
- Ensure the path source (GUIDToAssetPath, Selection.activeObject, etc.) is validated and non-null before use.
- Use a helper that returns empty string instead of null from path-resolution logic.
Example fix
// before
AssetDatabase.MakeEditable(resolvedPath);
// after
if (!string.IsNullOrEmpty(resolvedPath))
AssetDatabase.MakeEditable(resolvedPath); Defensive patterns
Strategy: validation
Validate before calling
if (!string.IsNullOrEmpty(path))
AssetDatabase.MakeEditable(path); Type guard
static bool IsValidAssetPath(string path) => !string.IsNullOrEmpty(path);
Try / catch
try { AssetDatabase.MakeEditable(path); }
catch (ArgumentNullException ex) when (ex.ParamName == "path")
{ Debug.LogWarning($"Cannot make editable: path is null"); } Prevention
- Validate asset paths with string.IsNullOrEmpty before VCS calls
- Ensure path sources (GUIDToAssetPath, Selection) are checked for null/empty
- Cache resolved paths and validate them before checkout operations
When it happens
Trigger: Calling AssetDatabase.MakeEditable(null) directly, or passing an asset path variable that was set from a query returning null (e.g., AssetDatabase.GUIDToAssetPath on an invalid GUID returns empty string, but other path APIs can return null).
Common situations: Custom checkout scripts, import post-processors, or tools that auto-checkout assets before modification where the path source can be null due to a missing asset, deleted file, or unresolvable GUID.
Related errors
- paths
- materialFolderPath
- assetOrMetaFilePaths
- outNotEditablePaths
- Cannot add dependency on invalid path.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/1d9b1ab86aa064f7.
Report an issue: GitHub.