Skip to content

Commit 1943399

Browse files
authored
Merge pull request #166 from Unity-Technologies/UNI-26822-move-editor-fbxprefab-to-autoupdater
UNI-26822 move editor only code in FbxPrefab to FbxAutoUpdater
2 parents 643b0ce + 77f2a2c commit 1943399

File tree

10 files changed

+1146
-1078
lines changed

10 files changed

+1146
-1078
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public static GameObject Convert (
199199
Object.DestroyImmediate(fbxPrefab);
200200
}
201201
fbxPrefab = unityGO.AddComponent<FbxPrefab>();
202-
fbxPrefab.SetSourceModel(unityMainAsset);
202+
var fbxPrefabUtility = new FbxPrefabAutoUpdater.FbxPrefabUtility (fbxPrefab);
203+
fbxPrefabUtility.SetSourceModel(unityMainAsset);
203204

204205
// Disconnect from the FBX file.
205206
PrefabUtility.DisconnectPrefabInstance(unityGO);

Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs

Lines changed: 1007 additions & 4 deletions
Large diffs are not rendered by default.

Assets/FbxExporters/Editor/FbxPrefabInspector.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ public override void OnInspectorGUI() {
1616
}
1717
EditorGUI.BeginDisabledGroup(isDisabled);
1818

19-
var oldFbxAsset = fbxPrefab.GetFbxAsset();
19+
var fbxPrefabUtility = new FbxPrefabAutoUpdater.FbxPrefabUtility (fbxPrefab);
20+
var oldFbxAsset = fbxPrefabUtility.GetFbxAsset();
2021
var newFbxAsset = EditorGUILayout.ObjectField("Source Fbx Asset", oldFbxAsset,
2122
typeof(GameObject), allowSceneObjects: false) as GameObject;
2223
if (newFbxAsset && !AssetDatabase.GetAssetPath(newFbxAsset).EndsWith(".fbx")) {
2324
Debug.LogError("FbxPrefab must point to an Fbx asset (or none).");
2425
} else if (newFbxAsset != oldFbxAsset) {
25-
fbxPrefab.SetSourceModel(newFbxAsset);
26+
fbxPrefabUtility.SetSourceModel(newFbxAsset);
2627
}
2728

2829
EditorGUI.EndDisabledGroup();

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void Init ()
3434
// Instantiate the fbx and create a prefab from it.
3535
// Delete the object right away (don't even wait for term).
3636
var fbxInstance = PrefabUtility.InstantiatePrefab(m_fbx) as GameObject;
37-
fbxInstance.AddComponent<FbxPrefab>().SetSourceModel(m_fbx);
37+
new FbxPrefabAutoUpdater.FbxPrefabUtility(fbxInstance.AddComponent<FbxPrefab>()).SetSourceModel(m_fbx);
3838
m_prefabPath = GetRandomPrefabAssetPath();
3939
m_prefab = PrefabUtility.CreatePrefab(m_prefabPath, fbxInstance);
4040
AssetDatabase.Refresh ();
@@ -47,7 +47,7 @@ public void BasicTest ()
4747
{
4848
var fbxPrefabPath = FbxPrefabAutoUpdater.FindFbxPrefabAssetPath();
4949
Assert.IsFalse(string.IsNullOrEmpty(fbxPrefabPath));
50-
Assert.IsTrue(fbxPrefabPath.EndsWith("FbxPrefab.cs"));
50+
Assert.IsTrue(fbxPrefabPath.EndsWith(FbxPrefabAutoUpdater.FBX_PREFAB_FILE));
5151

5252
Assert.IsTrue(FbxPrefabAutoUpdater.IsFbxAsset("Assets/path/to/foo.fbx"));
5353
Assert.IsFalse(FbxPrefabAutoUpdater.IsFbxAsset("Assets/path/to/foo.png"));
@@ -145,7 +145,7 @@ public void ExpensivePerformanceTest ()
145145
var instance = CreateGameObject("prefab_" + i);
146146
Assert.IsTrue(instance);
147147
var fbxPrefab = instance.AddComponent<FbxPrefab>();
148-
fbxPrefab.SetSourceModel(fbxFiles[i]);
148+
new FbxPrefabAutoUpdater.FbxPrefabUtility(fbxPrefab).SetSourceModel(fbxFiles[i]);
149149
PrefabUtility.CreatePrefab(GetRandomPrefabAssetPath(), fbxFiles[i]);
150150
}
151151
Debug.Log("Created prefabs in " + stopwatch.ElapsedMilliseconds);

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 69 additions & 65 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)