Skip to content

Commit e859fdf

Browse files
authored
Merge pull request #362 from Unity-Technologies/Uni-27534-MeshReferenceWrongPlace
Uni-27534-MeshReferenceWrongPlace-Fixed bug
2 parents c0d0e55 + d6ff458 commit e859fdf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,22 @@ public static Dictionary<string,GameObject> MapNameToSourceRecursive(GameObject
383383
/// </summary>
384384
public static void CopyComponents(GameObject to, GameObject from){
385385
var originalComponents = new List<Component>(to.GetComponents<Component> ());
386+
387+
// UNI-27534: This fixes the issue where the mesh collider would not update to point to the mesh in the fbx after export
388+
// Point the mesh included in the mesh collider to the mesh in the FBX file, which is the same as the one in mesh filter
389+
var toMeshCollider = to.GetComponent<MeshCollider>();
390+
var toMeshFilter = to.GetComponent<MeshFilter>();
391+
// if the mesh collider isn't pointing to the same mesh as in the current mesh filter then don't
392+
// do anything as it's probably pointing to a mesh in a different fbx
393+
if (toMeshCollider && toMeshFilter && toMeshCollider.sharedMesh == toMeshFilter.sharedMesh)
394+
{
395+
var fromFilter = from.GetComponent<MeshFilter>();
396+
if (fromFilter)
397+
{
398+
toMeshCollider.sharedMesh = fromFilter.sharedMesh;
399+
}
400+
}
401+
386402
// copy over meshes, materials, and nothing else
387403
foreach (var component in from.GetComponents<Component>()) {
388404
// ignore missing components

0 commit comments

Comments
 (0)