{"record":{"id":"5a55b2d6213b7ef2","repo":"Unity-Technologies/UnityCsReference","slug":"mesh-list-is-null","errorCode":null,"errorMessage":"Mesh list is null","messagePattern":"Mesh list is null","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/MeshUtility.bindings.cs","lineNumber":66,"sourceCode":"\n        extern internal static Vector2[] ComputeTextureBoundingHull(Texture texture, int vertexCount);\n\n        public static Mesh.MeshDataArray AcquireReadOnlyMeshData(Mesh mesh)\n        {\n            return new Mesh.MeshDataArray(mesh, false);\n        }\n\n        public static Mesh.MeshDataArray AcquireReadOnlyMeshData(Mesh[] meshes)\n        {\n            if (meshes == null)\n                throw new ArgumentNullException(nameof(meshes), \"Mesh array is null\");\n            return new Mesh.MeshDataArray(meshes, meshes.Length, false);\n        }\n\n        public static Mesh.MeshDataArray AcquireReadOnlyMeshData(List<Mesh> meshes)\n        {\n            if (meshes == null)\n                throw new ArgumentNullException(nameof(meshes), \"Mesh list is null\");\n            return new Mesh.MeshDataArray(NoAllocHelpers.ExtractArrayFromList(meshes), meshes.Count, false);\n        }\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":71,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/MeshUtility.bindings.cs#L48-L71","documentation":"Thrown by the List<Mesh> overload of AcquireReadOnlyMeshData when the meshes list is null. It mirrors the array overload's null check before extracting the internal array via NoAllocHelpers.ExtractArrayFromList.","triggerScenarios":"Calling AcquireReadOnlyMeshData((List<Mesh>)null), or passing a list field that was never initialized. Note the single-Mesh and array overloads have separate checks.","commonSituations":"Editor tooling that builds a List<Mesh> conditionally and passes the uninitialized field when the branch was not taken.","solutions":["Initialize the list (new List<Mesh>()) before calling, or skip the call when no meshes are available.","Null-check the list and surface a clearer error identifying the source.","Prefer passing an empty list over null to distinguish 'no meshes' from 'uninitialized'."],"exampleFix":"// before\nvar data = MeshUtility.AcquireReadOnlyMeshData(meshList);\n\n// after\nif (meshList == null) meshList = new List<Mesh>();\nif (meshList.Count == 0) return;\nvar data = MeshUtility.AcquireReadOnlyMeshData(meshList);","handlingStrategy":"type-guard","validationCode":"if (meshes == null) meshes = new List<Mesh>();\nif (meshes.Count == 0) return;","typeGuard":"static bool HasMeshes(List<Mesh> m) => m != null && m.Count > 0;","tryCatchPattern":"try { var data = MeshUtility.AcquireReadOnlyMeshData(meshes); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"meshes\") { Debug.LogWarning(\"No mesh list provided.\"); }","preventionTips":["Initialize lists before use","Pass empty lists rather than null","Distinguish empty from uninitialized"],"tags":["unity","editor","mesh","argument-validation","mesh-data"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}