Search Issue Tracker
Won't Fix
Votes
1
Found in [Package]
4.2.0
5.0.0-pre.1
Issue ID
FBX-437
Regression
No
FBX Exporter throws a KeyNotFoundException when exporting a high-polygon mesh
Reproduction steps:
# Open the attached “TempFBXExportRepro” project
# Open the “SampleScene” scene
# In the Hierarchy right-click on “DoesNotExport” GameObject
# In the context menu select “Export To FBX…”
Expected result: No errors in the Console
Actual result: Export is unsuccessful, error in the Console
Reproducible with: 4.2.0, 5.0.0-pre.1 (2020.3.42f1, 2021.3.15f1, 2022.1.24f1, 2022.2.1f1, 2023.1.0a22)
Reproduced on: Windows 10
Part of the error:
KeyNotFoundException: The given key '(NaN, NaN, NaN)' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <d6232873609549b8a045fa15811a5bd3>:0)
UnityEditor.Formats.Fbx.Exporter.ModelExporter.ExportMesh (UnityEditor.Formats.Fbx.Exporter.ModelExporter+MeshInfo meshInfo, Autodesk.Fbx.FbxNode fbxNode) (at Library/PackageCache/com.unity.formats.fbx@4.1.2/Editor/FbxExporter.cs:892)
Comments (1)
-
rachid_bouemama
Feb 16, 2025 08:41
#look for this method
bool ExportMesh(MeshInfo meshInfo, FbxNode fbxNode)
{
...
#inside this loop
foreach (int val in vertOrder)
{
int polyVert = indices[polySize * f + val];#Add this :
// Check for NaN values before attempting to access the dictionary
if (float.IsNaN(meshInfo.Vertices[polyVert].x) || float.IsNaN(meshInfo.Vertices[polyVert].y) || float.IsNaN(meshInfo.Vertices[polyVert].z))
{
continue; // Skip this iteration if NaN is found
}
#End Fix
#rest code..
unmergedPolygons.Add(polyVert);polyVert = ControlPointToIndex[meshInfo.Vertices[polyVert]];
fbxMesh.AddPolygon(polyVert);
...
}}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash on mecanim::animation::TransformValuesFromClip when entering the Play Mode in a project with Animancer Pro v8
- Connection to Named Pipes fails when server and client are run
- Subgraph Block cannot be dragged and dropped to the workspace and it throws errors
- "Capsule" and "Cylinder" Shader Graph preview types can't be freely rotated
- Cubemap mipmaps display differently between Editor and Player when using custom mipmaps
Resolution Note:
Closing this bug as first it is very old and unlikely to still be a problem.
Also, looking at the code, this looks like a faulty input mesh asset that contains NaN values.