Siccity / GLTFUtility

Simple GLTF importer for Unity
MIT License
996 stars 218 forks source link

Fixes unchecked access of primitives.targets #227

Open cneumann opened 1 year ago

cneumann commented 1 year ago

Exporting models from Maya I get meshes that look like (omitting attribute details for brevity):

{
  "name": "Blob1Shape",
  "extras": {
    "targetNames": []
  },
  "primitives": [
    {
      "attributes": { /*...*/ },
      "indices": 0,
      "mode": 4,
      "material": 0
    }
  ]
}

Note that there is no targets property on the primitive and the targetNames extra is an empty array. The empty targetNames array makes hasTargetNames (Assets/GLTFUtility/Scripts/Spec/GLTFMesh.cs:200) true causing a check for matching array lengths. The latter previously unconditionally accessed GLTFPrimitive.targets which is null for this mesh, causing the mesh to not be imported.