{"record":{"id":"7082f3846c517233","repo":"Unity-Technologies/UnityCsReference","slug":"unknown-vertex-format-format","errorCode":null,"errorMessage":"Unknown vertex format {format}","messagePattern":"Unknown vertex format (.+?)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/ModelInspector.cs","lineNumber":322,"sourceCode":"            switch (format)\n            {\n                case VertexAttributeFormat.Float32:\n                case VertexAttributeFormat.UInt32:\n                case VertexAttributeFormat.SInt32:\n                    return 4;\n                case VertexAttributeFormat.Float16:\n                case VertexAttributeFormat.UNorm16:\n                case VertexAttributeFormat.SNorm16:\n                case VertexAttributeFormat.UInt16:\n                case VertexAttributeFormat.SInt16:\n                    return 2;\n                case VertexAttributeFormat.UNorm8:\n                case VertexAttributeFormat.SNorm8:\n                case VertexAttributeFormat.UInt8:\n                case VertexAttributeFormat.SInt8:\n                    return 1;\n                default:\n                    throw new ArgumentOutOfRangeException(nameof(format), format, $\"Unknown vertex format {format}\");\n            }\n        }\n\n        static string GetAttributeString(VertexAttributeDescriptor attr)\n        {\n            var format = attr.format;\n            var dimension = attr.dimension;\n            var str = $\"{format} x {dimension} ({ConvertFormatToSize(format) * dimension} bytes)\";\n            if (attr.stream != 0)\n                str += $\", stream {attr.stream}\";\n            return str;\n        }\n\n        static long CalcTotalIndices(Mesh mesh)\n        {\n            return mesh.GetTotalIndexCount();\n        }\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/ModelInspector.cs#L304-L340","documentation":"Thrown by ConvertFormatToSize when a VertexAttributeFormat value is not one of the handled cases (Float32, Float16, the 16/8-bit UNorm/SNorm/UInt/SInt variants). Acts as a defensive exhaustive-switch guard for a format expected to map to a byte size.","triggerScenarios":"Mesh inspection path (ModelInspector / mesh import preview) encountering a vertex attribute format introduced in a newer Unity version than the editor handling it, or a corrupt/malformed mesh with an out-of-range format value.","commonSituations":"Opening a mesh serialized by a newer Unity build that uses a VertexAttributeFormat not present in the running editor's enum. Asset corruption producing an invalid format integer. Editor version mismatch on imported models.","solutions":["Open the project in the Unity version that matches or exceeds the one that produced the mesh.","Re-import / re-export the model from source so vertex formats align with the editor.","If writing tooling, validate attr.format against the known set before calling ConvertFormatToSize."],"exampleFix":"// before\nint size = ConvertFormatToSize(attr.format);\n\n// after\nvar known = attr.format switch {\n    VertexAttributeFormat.Float32 => 4,\n    VertexAttributeFormat.Float16 => 2,\n    // ...\n    _ => -1\n};\nif (known < 0) { Debug.LogWarning($\"Unsupported vertex format {attr.format}\"); return; }","handlingStrategy":"validation","validationCode":"static readonly HashSet<VertexAttributeFormat> s_KnownFormats = new HashSet<VertexAttributeFormat> {\n    VertexAttributeFormat.Float32, VertexAttributeFormat.Float16,\n    VertexAttributeFormat.UNorm16, VertexAttributeFormat.SNorm16,\n    VertexAttributeFormat.UInt16, VertexAttributeFormat.SInt16,\n    VertexAttributeFormat.UNorm8, VertexAttributeFormat.SNorm8,\n    VertexAttributeFormat.UInt8, VertexAttributeFormat.SInt8\n};\nbool IsKnownFormat(VertexAttributeDescriptor a) => s_KnownFormats.Contains(a.format);","typeGuard":"static bool IsKnownFormat(VertexAttributeFormat f) => Enum.IsDefined(typeof(VertexAttributeFormat), f);","tryCatchPattern":"try { ConvertFormatToSize(attr.format); }\ncatch (ArgumentOutOfRangeException) { Debug.LogWarning($\"Unknown format {attr.format}\"); }","preventionTips":["Match editor version to the mesh producer.","Re-import models from source."],"tags":["unity","editor","mesh","vertex-format","version-mismatch"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}