Skip to content

Commit ca7d597

Browse files
committed
fix so unit tests pass
1 parent d25a50a commit ca7d597

File tree

5 files changed

+31
-28
lines changed

5 files changed

+31
-28
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3640,7 +3640,7 @@ public static string ExportObjects (
36403640
clipList.Add (timelineClip);
36413641
animationExportData = fbxExporter.GetTimelineAnimationExportData (rootObject, clipList);
36423642
}
3643-
else if (exportOptions.GetModelAnimIncludeOption () == ExportModelSettingsSerialize.Include.Anim) {
3643+
else if (fbxExporter.ExportOptions.GetModelAnimIncludeOption () == ExportModelSettingsSerialize.Include.Anim) {
36443644
HashSet<GameObject> gos = new HashSet<GameObject> ();
36453645
foreach (var obj in objects) {
36463646
gos.Add (ModelExporter.GetGameObject (obj));

Assets/FbxExporters/Editor/UnitTests/DefaultSelectionTest.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ namespace FbxExporters.UnitTests
1717
public class DefaultSelectionTest : ExporterTestBase
1818
{
1919
protected GameObject m_root;
20-
protected ExportModelSettingsSerialize.ObjectPosition m_centerObjectsSetting;
20+
protected ExportModelSettings m_centerObjectsSetting;
2121

2222
[SetUp]
2323
public override void Init ()
2424
{
2525
base.Init();
26-
// m_centerObjectsSetting = FbxExporters.EditorTools.ExportSettings.GetObjectPosition();
26+
m_centerObjectsSetting = ScriptableObject.CreateInstance (typeof(ExportModelSettings)) as ExportModelSettings;
2727
}
2828

2929
[TearDown]
@@ -33,8 +33,6 @@ public override void Term ()
3333
if (m_root) {
3434
UnityEngine.Object.DestroyImmediate (m_root);
3535
}
36-
// restore original setting
37-
// FbxExporters.EditorTools.ExportSettings.SetObjectPosition(m_centerObjectsSetting);
3836
}
3937

4038
[Test]
@@ -63,12 +61,12 @@ public void TestDefaultSelection ()
6361
Assert.IsNotNull (m_root);
6462

6563
// test without centered objects
66-
//FbxExporters.EditorTools.ExportSettings.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.WorldAbsolute);
64+
m_centerObjectsSetting.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.WorldAbsolute);
6765

6866
// test Export Root
6967
// Expected result: everything gets exported
7068
// Expected transform: all transforms unchanged
71-
var exportedRoot = ExportSelection (new Object[]{ m_root });
69+
var exportedRoot = ExportSelection (m_root, m_centerObjectsSetting);
7270
CompareHierarchies (m_root, exportedRoot, true, false);
7371
CompareGlobalTransform (exportedRoot.transform, m_root.transform);
7472

@@ -77,15 +75,15 @@ public void TestDefaultSelection ()
7775
// Expected transform: all transforms unchanged
7876
var parent1 = m_root.transform.Find ("Parent1");
7977
var child1 = parent1.Find ("Child1");
80-
exportedRoot = ExportSelection (new Object[]{ parent1.gameObject, child1.gameObject });
78+
exportedRoot = ExportSelection (new Object[]{ parent1.gameObject, child1.gameObject }, m_centerObjectsSetting);
8179
CompareHierarchies (parent1.gameObject, exportedRoot, true, false);
8280
CompareGlobalTransform (exportedRoot.transform, parent1);
8381

8482
// test Export Child2
8583
// Expected result: Child2
8684
// Expected transform: Child2 unchanged
8785
var child2 = parent1.Find ("Child2").gameObject;
88-
exportedRoot = ExportSelection (new Object[]{ child2 });
86+
exportedRoot = ExportSelection (child2, m_centerObjectsSetting);
8987
CompareHierarchies (child2, exportedRoot, true, false);
9088
CompareGlobalTransform (exportedRoot.transform, child2.transform);
9189

@@ -98,20 +96,20 @@ public void TestDefaultSelection ()
9896
var goExportSet = new GameObject[]{ child2.gameObject, parent2.gameObject };
9997

10098
// test without centering objects
101-
//FbxExporters.EditorTools.ExportSettings.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.WorldAbsolute);
99+
m_centerObjectsSetting.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.WorldAbsolute);
102100

103-
exportedRoot = ExportSelection (exportSet);
101+
exportedRoot = ExportSelection (exportSet, m_centerObjectsSetting);
104102
List<GameObject> children = new List<GameObject> ();
105103
foreach (Transform child in exportedRoot.transform) {
106104
children.Add (child.gameObject);
107105
}
108106
CompareHierarchies (new GameObject[]{ child2, parent2.gameObject }, children.ToArray ());
109107

110108
// test with centered objects
111-
//FbxExporters.EditorTools.ExportSettings.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.LocalCentered);
109+
m_centerObjectsSetting.SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition.LocalCentered);
112110
var newCenter = FbxExporters.Editor.ModelExporter.FindCenter (goExportSet);
113111

114-
exportedRoot = ExportSelection (exportSet);
112+
exportedRoot = ExportSelection (exportSet, m_centerObjectsSetting);
115113
children = new List<GameObject> ();
116114
foreach (Transform child in exportedRoot.transform) {
117115
children.Add (child.gameObject);

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,27 @@ public virtual void Init()
221221
/// </summary>
222222
/// <returns>Root of Model Prefab.</returns>
223223
/// <param name="selected">Objects to export.</param>
224-
protected virtual GameObject ExportSelection(params Object[] selected)
224+
protected virtual GameObject ExportSelection(Object selected, EditorTools.IExportOptions exportOptions = null)
225225
{
226226
// export selected to a file, then return the root
227227
var filename = GetRandomFileNamePath();
228-
return ExportSelection (filename, selected);
228+
return ExportSelection (filename, selected, exportOptions);
229229
}
230230

231-
protected virtual GameObject ExportSelection(string filename, params Object[] selected){
231+
protected virtual GameObject ExportSelection(Object[] selected, EditorTools.IExportOptions exportOptions = null){
232+
var filename = GetRandomFileNamePath();
233+
return ExportSelection (filename, selected, exportOptions);
234+
}
235+
236+
protected virtual GameObject ExportSelection(string filename, Object selected, EditorTools.IExportOptions exportOptions = null)
237+
{
238+
// export selected to a file, then return the root
239+
return ExportSelection (filename, new Object[]{selected}, exportOptions);
240+
}
241+
242+
protected virtual GameObject ExportSelection(string filename, Object[] selected, EditorTools.IExportOptions exportOptions = null){
232243
Debug.unityLogger.logEnabled = false;
233-
var fbxFileName = FbxExporters.Editor.ModelExporter.ExportObjects (filename, selected) as string;
244+
var fbxFileName = FbxExporters.Editor.ModelExporter.ExportObjects (filename, selected, exportOptions) as string;
234245
Debug.unityLogger.logEnabled = true;
235246

236247
Assert.IsNotNull (fbxFileName);
@@ -250,13 +261,6 @@ protected virtual GameObject ExportSelection(string filename, params Object[] se
250261
return fbxRoot;
251262
}
252263

253-
protected virtual string ExportSelectedObjects(string filename, params Object[] selected)
254-
{
255-
string fbxFileName = FbxExporters.Editor.ModelExporter.ExportObjects(filename, selected);
256-
257-
return fbxFileName;
258-
}
259-
260264
/// <summary>
261265
/// Exports a single hierarchy to a random fbx file.
262266
/// </summary>

Assets/FbxExporters/Editor/UnitTests/FbxExportSettingsTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ public void TestGetSetFields ()
180180
ExportSettings.AddFbxSavePath ("/a\\b/c/\\");
181181
ExportSettings.AddPrefabSavePath ("/a\\b/c/\\");
182182

183-
Assert.That (ExportSettings.GetRelativeFbxSavePaths () [0], Is.EqualTo ("Assets \u2044 a⁄b⁄c"));
184-
Assert.That (ExportSettings.GetRelativePrefabSavePaths () [0], Is.EqualTo ("Assets \u2044 a⁄b⁄c"));
183+
string forwardSlash = " ⁄ "; // special unicode forward slash
184+
Assert.That (ExportSettings.GetRelativeFbxSavePaths () [0], Is.EqualTo (string.Format("Assets{0}a{0}b{0}c", forwardSlash)));
185+
Assert.That (ExportSettings.GetRelativePrefabSavePaths () [0], Is.EqualTo (string.Format("Assets{0}a{0}b{0}c", forwardSlash)));
185186

186187
var platformPath = Path.Combine ("a", Path.Combine ("b", "c"));
187188
Assert.AreEqual (Path.Combine (appDataPath, platformPath), ExportSettings.GetFbxAbsoluteSavePath ());

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void RemappingTest()
210210
//export our updated hierarchy to the same file path as the original
211211
SleepForFileTimestamp();
212212
// "Import" model to Unity (Exporting modified FBX to Unity to see if the remapping works)
213-
ExportSelectedObjects(filePath, cube2);
213+
ExportSelection(filePath, cube2);
214214
AssetDatabase.Refresh();
215215

216216
// Assert Check Sphere = SphereFBX
@@ -272,7 +272,7 @@ public void RemappingTest()
272272
//export our updated hierarchy to the same file path as the original
273273
SleepForFileTimestamp();
274274
// "Import" model to Unity (Exporting modified FBX to Unity to see if the remapping works)
275-
ExportSelectedObjects(filePath, cube2);
275+
ExportSelection(filePath, cube2);
276276
AssetDatabase.Refresh();
277277

278278
// Assert Check Sphere = Sphere and has been changed by the Auto-Updater.

0 commit comments

Comments
 (0)