Skip to content

Commit 02596c1

Browse files
authored
Merge pull request #500 from Unity-Technologies/UT-3243-fix-mesh-separating-from-bones-in-maya
UT-3243 fix mesh separating from bones in Maya
2 parents 0da9bcf + cd134c2 commit 02596c1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

com.unity.formats.fbx/Editor/FbxExporter.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,8 +2887,28 @@ private bool ExportBoneTransform(
28872887
fbxSkeleton.Size.Set (1.0f * UnitScaleFactor);
28882888
fbxNode.SetNodeAttribute (fbxSkeleton);
28892889
}
2890-
var fbxSkeletonType = rootBone != unityBone
2891-
? FbxSkeleton.EType.eLimbNode : FbxSkeleton.EType.eRoot;
2890+
var fbxSkeletonType = FbxSkeleton.EType.eLimbNode;
2891+
2892+
// Only set the rootbone's skeleton type to FbxSkeleton.EType.eRoot
2893+
// if it has at least one child that is also a bone.
2894+
// Otherwise if it is marked as Root but has no bones underneath,
2895+
// Maya will import it as a Null object instead of a bone.
2896+
if (rootBone == unityBone && rootBone.childCount > 0)
2897+
{
2898+
var hasChildBone = false;
2899+
foreach (Transform child in unityBone)
2900+
{
2901+
if (boneDict.ContainsKey(child))
2902+
{
2903+
hasChildBone = true;
2904+
break;
2905+
}
2906+
}
2907+
if (hasChildBone)
2908+
{
2909+
fbxSkeletonType = FbxSkeleton.EType.eRoot;
2910+
}
2911+
}
28922912
fbxSkeleton.SetSkeletonType (fbxSkeletonType);
28932913

28942914
var bindPoses = skinnedMesh.sharedMesh.bindposes;

0 commit comments

Comments
 (0)