Skip to content

Commit e5736aa

Browse files
authored
Merge pull request #142 from Unity-Technologies/uni-25528-prefab-duplicate
UNI-25528; handle Convert-to-prefab on an FbxPrefab.
2 parents e04d8d4 + 1409916 commit e5736aa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,12 @@ public static GameObject Convert (
173173
SetupImportedGameObject (toConvert, unityGO);
174174

175175
// Set up the FbxPrefab component so it will auto-update.
176-
var fbxPrefab = unityGO.AddComponent<FbxPrefab>();
176+
// Make sure to delete whatever FbxPrefab history we had.
177+
var fbxPrefab = unityGO.GetComponent<FbxPrefab>();
178+
if (fbxPrefab) {
179+
Object.DestroyImmediate(fbxPrefab);
180+
}
181+
fbxPrefab = unityGO.AddComponent<FbxPrefab>();
177182
fbxPrefab.SetSourceModel(unityMainAsset);
178183

179184
// Disconnect from the FBX file.

Assets/FbxExporters/Editor/UnitTests/ConvertToModelTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ public void BasicTest()
165165
var assetFullPath = Path.GetFullPath(Path.Combine(Application.dataPath,
166166
"../" + assetRelativePath));
167167
Assert.AreEqual(Path.GetFullPath(path), Path.GetDirectoryName(assetFullPath));
168+
169+
// Convert it again, make sure there's only one FbxPrefab (see UNI-25528).
170+
var cubePrefabInstance2 = ConvertToModel.Convert(cubePrefabInstance,
171+
directoryFullPath: path, keepOriginal: false);
172+
Assert.That(cubePrefabInstance2.GetComponents<FbxPrefab>().Length, Is.EqualTo(1));
168173
}
169174
}
170175
}

0 commit comments

Comments
 (0)