Unity-Technologies/UnityCsReference · error · ArgumentNullException

paths

Error message

paths

What it means

The array overload of AssetDatabase.MakeEditable checks out multiple assets via the version-control provider. It throws ArgumentNullException when the paths array is null, because the null guard fires before Provider.HandlePreCheckoutCallback and the native checkout. The array may be empty (no checkout occurs) but must not be null.

Source

Thrown at Editor/Mono/AssetDatabase/AssetDatabase.cs:149

        }

        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;
            if (result && !Provider.MakeEditableImpl(paths, prompt, changeSet, outNotEditablePaths))
                result = false;
            UnityEngine.Profiling.Profiler.EndSample();
            return result;
        }
    }
}

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Ensure paths is never null: paths = paths ?? Array.Empty<string>().
  2. Validate the collection logic that produces paths so it returns empty arrays, not null.
  3. Guard before the call: if (paths != null && paths.Length > 0) AssetDatabase.MakeEditable(paths).

Example fix

// before
string[] paths = CollectAssetsToCheckout();
AssetDatabase.MakeEditable(paths);

// after
string[] paths = CollectAssetsToCheckout() ?? Array.Empty<string>();
if (paths.Length > 0)
    AssetDatabase.MakeEditable(paths);
Defensive patterns

Strategy: validation

Validate before calling

string[] paths = CollectPaths() ?? Array.Empty<string>();
if (paths.Length > 0)
    AssetDatabase.MakeEditable(paths);

Type guard

static bool IsValidPathArray(string[] paths) => paths != null && paths.Length > 0;

Try / catch

try { AssetDatabase.MakeEditable(paths); }
catch (ArgumentNullException ex) when (ex.ParamName == "paths")
{ Debug.LogWarning("Cannot make editable: paths array is null"); }

Prevention

When it happens

Trigger: Calling AssetDatabase.MakeEditable(null) or passing a null array from a LINQ query, a dynamically built list that was never materialized, or a field cleared to null. Distinguish from the single-path overload (error 22) which takes a string.

Common situations: Batch checkout tools, pre-import hooks, or build scripts that collect asset paths programmatically and can produce null when the selection or filter yields nothing and the collection code returns null instead of an empty array.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/969c18921615511e. Report an issue: GitHub.