Skip to content

Commit d7d0384

Browse files
authored
Ut 3710 fix export settings presets not working (#542)
* fix export settings not getting serialized to preset * add unit test for presets * update changelog
1 parent 7fe3cfe commit d7d0384

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes in Fbx Exporter
22

3+
## [UNRELEASED] - 2020-09-29
4+
### Fixed
5+
- Fix Export Model and Convert to Prefab Variant setting presets not serializing settings properly.
6+
37
## [3.2.1-preview.2] - 2020-08-05
48
### Added
59
- Add an export option to preserve model import settings when overwriting an fbx file.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ internal interface IExportOptions {
123123

124124
internal abstract class ExportOptionsSettingsBase<T> : ScriptableObject where T : ExportOptionsSettingsSerializeBase, new()
125125
{
126+
[SerializeField]
126127
private T m_info = new T();
127-
public T info {
128+
public T info
129+
{
128130
get { return m_info; }
129131
set { m_info = value; }
130132
}

com.unity.formats.fbx/Tests/FbxTests/FbxExportSettingsTest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using UnityEditor.Formats.Fbx.Exporter;
55
using NUnit.Framework;
6+
using UnityEditor.Presets;
67

78
namespace FbxExporter.UnitTests
89
{
@@ -490,5 +491,36 @@ private void TestLocations(Dictionary<string,List<string>> data)
490491
}
491492
}
492493

494+
[Test]
495+
public void TestExportSettingsPresets()
496+
{
497+
// make sure that the export settings exist
498+
ExportSettings.instance.LoadDefaults();
499+
500+
var exportModelSettings = ExportSettings.instance.ExportModelSettings;
501+
var convertPrefabSettings = ExportSettings.instance.ConvertToPrefabSettings;
502+
503+
// test ExportModelSettings preset
504+
exportModelSettings.info.SetExportFormat(ExportSettings.ExportFormat.Binary);
505+
Assert.That(exportModelSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.Binary));
506+
507+
var exportModelPreset = new Preset(exportModelSettings);
508+
exportModelSettings.info.SetExportFormat(ExportSettings.ExportFormat.ASCII);
509+
Assert.That(exportModelSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.ASCII));
510+
511+
exportModelPreset.ApplyTo(exportModelSettings);
512+
Assert.That(exportModelSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.Binary));
513+
514+
// test ConvertToPrefabSettings preset
515+
convertPrefabSettings.info.SetExportFormat(ExportSettings.ExportFormat.Binary);
516+
Assert.That(convertPrefabSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.Binary));
517+
518+
var convertPrefabPreset = new Preset(convertPrefabSettings);
519+
convertPrefabSettings.info.SetExportFormat(ExportSettings.ExportFormat.ASCII);
520+
Assert.That(convertPrefabSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.ASCII));
521+
522+
convertPrefabPreset.ApplyTo(convertPrefabSettings);
523+
Assert.That(convertPrefabSettings.info.ExportFormat, Is.EqualTo(ExportSettings.ExportFormat.Binary));
524+
}
493525
}
494526
}

0 commit comments

Comments
 (0)